Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Pikachu-Power
Post Prodigy
Post Prodigy

CALCULATE with running filter

hi all,

 

I have a measure like

 

CALCULATE ( Measure, Table2[Category] = "A" )

+ CALCULATE ( Measure, Table2[Category] = "B" )

+ CALCULATE ( Measure, Table2[Category] = "C" )

+ CALCULATE ( Measure, Table2[Category] = "D" )

+ CALCULATE ( Measure, Table2[Category] = "E" )

and so on...

 

Can I write it more compact? With a kind of running Filter?

 

Thanks for ideas.

1 ACCEPTED SOLUTION

Yes, you could do it like

Combined measure =
VAR summaryTable =
    ADDCOLUMNS (
        CALCULATETABLE (
            VALUES ( 'Table2'[Category] ),
            KEEPFILTERS('Table2'[Category] IN { "A", "B", "C" })
        ),
        "@val", [Base Measure]
    )
RETURN
    SUMX ( summaryTable, [@val] )

View solution in original post

3 REPLIES 3
Pikachu-Power
Post Prodigy
Post Prodigy

Thank you it worked 👍

 

The measure dont react to a slicer with A, B and C. Is it also possible to write it in such way that I can also filter it to A, B and C?

Yes, you could do it like

Combined measure =
VAR summaryTable =
    ADDCOLUMNS (
        CALCULATETABLE (
            VALUES ( 'Table2'[Category] ),
            KEEPFILTERS('Table2'[Category] IN { "A", "B", "C" })
        ),
        "@val", [Base Measure]
    )
RETURN
    SUMX ( summaryTable, [@val] )
johnt75
Super User
Super User

You could do something like 

Combined measure =
VAR summaryTable =
    ADDCOLUMNS (
        CALCULATETABLE (
            VALUES ( 'Table2'[Category] ),
            'Table2'[Category] IN { "A", "B", "C" }
        ),
        "@val", [Base Measure]
    )
RETURN
    SUMX ( summaryTable, [@val] )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.