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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
reltakeasy
Regular Visitor

Calculated measure is not working when i use slicers

Hello there, 

 

I am new to power bi. I want to transfer a financial report with a very strict and specific format into power bi. So  I have created a table called 'Template' with 3 columns, 'Description', 'Row', and 'GL code'. The description is what the user wants to see, the row is the row number according to Excel.  Also, I have a table called Data which has these columns: 'Amount', 'Date', and 'GL Code'.

Row GL CodeDescription
1890Product 1
2871Product 2
.........
31nullTotal Product 1 +2

Data Table:

Date GL CodeAmount
1/1/2023      8711.40
1/1/20238902.80
2/1/20238902.80

Some rows have to do some sum based on GL Code. For example, when the row number is 31, they must sum the amount with GL Codes 890 and 871. 

 

So, I wrote a DAX code like this:

SWITCH(true(), MAX('Template'[Row])=31CALCULATE(SUM(Data[Amount]), FILTER(all('Template'), 'Template'[GL Code] in {890,871
})),0)


It works when I don't use slicers but they give the total for the whole dates. When I use the slicer with Date, it always returns the value 0. What can cause that?

 

Any help is appreciated.

 

Thanks in advance 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @reltakeasy ,

You can update the formula of your measure as below, please find the details in the attachment.

Measure = 
IF (
    SELECTEDVALUE ( 'Template'[Row] ) = 31,
    CALCULATE (
        SUM ( 'Data'[Amount] ),
        FILTER ( 'Data', 'Data'[GL Code] IN { 890, 871 } )
    ),
    CALCULATE (
        SUM ( 'Data'[Amount] ),
        FILTER ( 'Data', 'Data'[GL Code] = SELECTEDVALUE ( 'Template'[GL Code] ) )
    )
)Measure = 
IF (
    SELECTEDVALUE ( 'Template'[Row] ) = 31,
    CALCULATE (
        SUM ( 'Data'[Amount] ),
        FILTER ( 'Data', 'Data'[GL Code] IN { 890, 871 } )
    ),
    CALCULATE (
        SUM ( 'Data'[Amount] ),
        FILTER ( 'Data', 'Data'[GL Code] = SELECTEDVALUE ( 'Template'[GL Code] ) )
    )
)

vyiruanmsft_0-1686119799439.png

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @reltakeasy ,

You can update the formula of your measure as below, please find the details in the attachment.

Measure = 
IF (
    SELECTEDVALUE ( 'Template'[Row] ) = 31,
    CALCULATE (
        SUM ( 'Data'[Amount] ),
        FILTER ( 'Data', 'Data'[GL Code] IN { 890, 871 } )
    ),
    CALCULATE (
        SUM ( 'Data'[Amount] ),
        FILTER ( 'Data', 'Data'[GL Code] = SELECTEDVALUE ( 'Template'[GL Code] ) )
    )
)Measure = 
IF (
    SELECTEDVALUE ( 'Template'[Row] ) = 31,
    CALCULATE (
        SUM ( 'Data'[Amount] ),
        FILTER ( 'Data', 'Data'[GL Code] IN { 890, 871 } )
    ),
    CALCULATE (
        SUM ( 'Data'[Amount] ),
        FILTER ( 'Data', 'Data'[GL Code] = SELECTEDVALUE ( 'Template'[GL Code] ) )
    )
)

vyiruanmsft_0-1686119799439.png

Best Regards

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors