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

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

Reply
teefy
Frequent Visitor

Setting calculation level of DAX formulas, independent of what is shown in visual

Hi,

 

I am calculating a delta between 2 columns, and classifying them as either an Increase or Decrease. This is all done as Measures, not columns, since the Value Date 1 & 2 are dynamically adjusted by date slicers on the page.

 

This works fine in a detail table - e.g. at a Material and Plant level:

teefy_1-1706546553894.png

 

I've created a slicer to filter the Delta Type (Increase/Decrease), and have a visual level filter that is driven by the slicer selection to include/exclude data accordingly using another measure. E.g. if I filter for 'Decrease' this works as expected:

teefy_3-1706547385964.png

 

Where I'm stuck is if I want to summarize at a different level, e.g. Plant only and I want to review the impact of only Decreases. As soon as I take 'Material' out of the table, the measures calculate at a different level, giving the net overall delta:

teefy_2-1706547064235.png

This isn't what I want to see -- having sliced to show 'Decreases' I don't want the increases being considered in the calcualtions.

 

What I'd like the table to show is the following, with only the 2 'Decrease' lines being shown at a summary level of Plant without Material:

teefy_4-1706547661936.png

 

Can anyone please help point me in the correct direction? I've tried various approaches, but can't seem to get it to calculate as needed.

 

Sample PBIX File 

 

Many thanks in advance for any support!

 

1 ACCEPTED SOLUTION
talespin
Solution Sage
Solution Sage

Hi @teefy ,

 

Thank you for sharing pbix file.

 

You need to incorporate Delta type slicer value into your calculation for value measures. Please note that it will only work for Material and Plant, if you add any other column to visual, your measure might not give correct results and you may need to modify SUMMARIZE to account for that. Hope this helps.

 

I am grouping by Material and Plant, checking value2-value1 and then calculating which value to include/exclude and at end SUM. Also I assume you understand what you are doing, some times calculation shouldn't be additive, that depends on what the business rules is, how you want to see that numbers.

 

Value Date 1 =
VAR _DeltaType = SELECTEDVALUE('Value Delta Direction'[Value])

RETURN
SUMX(
        ADDCOLUMNS(
                    ADDCOLUMNS(
                                SUMMARIZE('Table', 'Table'[Material], 'Table'[Plant]),
                                "VDt1",CALCULATE(SUM('Table'[Value]), USERELATIONSHIP('Table'[Report Date], 'Compare Date 1'[Report Date])),
                                "VDt2",CALCULATE(SUM('Table'[Value]), USERELATIONSHIP('Table'[Report Date], 'Compare Date 2'[Report Date]))
                    ),
                    "Delta", [VDt2] - [VDt1]
        ),
        if ( _DeltaType = "Decrease", if( [Delta] < 0, [VDt1], BLANK()),  if( [Delta] > 0, [VDt1], BLANK()) )
)
 
 
Value Date 2 =
VAR _DeltaType = SELECTEDVALUE('Value Delta Direction'[Value])

RETURN
SUMX(
        ADDCOLUMNS(
                    ADDCOLUMNS(
                                SUMMARIZE('Table', 'Table'[Material], 'Table'[Plant]),
                                "VDt1",CALCULATE(SUM('Table'[Value]), USERELATIONSHIP('Table'[Report Date], 'Compare Date 1'[Report Date])),
                                "VDt2",CALCULATE(SUM('Table'[Value]), USERELATIONSHIP('Table'[Report Date], 'Compare Date 2'[Report Date]))
                    ),
                    "Delta", [VDt2] - [VDt1]
        ),
        if ( _DeltaType = "Decrease", if( [Delta] < 0, [VDt2], BLANK()),  if( [Delta] > 0, [VDt2], BLANK()) )
)

talespin_0-1706597872664.png

 

View solution in original post

4 REPLIES 4
talespin
Solution Sage
Solution Sage

Hi @teefy ,

 

Thank you for sharing pbix file.

 

You need to incorporate Delta type slicer value into your calculation for value measures. Please note that it will only work for Material and Plant, if you add any other column to visual, your measure might not give correct results and you may need to modify SUMMARIZE to account for that. Hope this helps.

 

I am grouping by Material and Plant, checking value2-value1 and then calculating which value to include/exclude and at end SUM. Also I assume you understand what you are doing, some times calculation shouldn't be additive, that depends on what the business rules is, how you want to see that numbers.

 

Value Date 1 =
VAR _DeltaType = SELECTEDVALUE('Value Delta Direction'[Value])

RETURN
SUMX(
        ADDCOLUMNS(
                    ADDCOLUMNS(
                                SUMMARIZE('Table', 'Table'[Material], 'Table'[Plant]),
                                "VDt1",CALCULATE(SUM('Table'[Value]), USERELATIONSHIP('Table'[Report Date], 'Compare Date 1'[Report Date])),
                                "VDt2",CALCULATE(SUM('Table'[Value]), USERELATIONSHIP('Table'[Report Date], 'Compare Date 2'[Report Date]))
                    ),
                    "Delta", [VDt2] - [VDt1]
        ),
        if ( _DeltaType = "Decrease", if( [Delta] < 0, [VDt1], BLANK()),  if( [Delta] > 0, [VDt1], BLANK()) )
)
 
 
Value Date 2 =
VAR _DeltaType = SELECTEDVALUE('Value Delta Direction'[Value])

RETURN
SUMX(
        ADDCOLUMNS(
                    ADDCOLUMNS(
                                SUMMARIZE('Table', 'Table'[Material], 'Table'[Plant]),
                                "VDt1",CALCULATE(SUM('Table'[Value]), USERELATIONSHIP('Table'[Report Date], 'Compare Date 1'[Report Date])),
                                "VDt2",CALCULATE(SUM('Table'[Value]), USERELATIONSHIP('Table'[Report Date], 'Compare Date 2'[Report Date]))
                    ),
                    "Delta", [VDt2] - [VDt1]
        ),
        if ( _DeltaType = "Decrease", if( [Delta] < 0, [VDt2], BLANK()),  if( [Delta] > 0, [VDt2], BLANK()) )
)

talespin_0-1706597872664.png

 

Thank you @talespin so much for your solution! I made a tiny tweak to the final part, and its working really well. I really appreciate your insights and the time taken to look into this for me.

 

Value Date 1 = 
VAR _DeltaType = SELECTEDVALUE('Value Delta Direction'[Value])
RETURN
SUMX(
    ADDCOLUMNS(
        ADDCOLUMNS(
            SUMMARIZE('Table', 'Table'[Material], 'Table'[Plant]),
            "VDt1", CALCULATE(SUM('Table'[Value]), USERELATIONSHIP('Table'[Report Date], 'Compare Date 1'[Report Date])),
            "VDt2", CALCULATE(SUM('Table'[Value]), USERELATIONSHIP('Table'[Report Date], 'Compare Date 2'[Report Date]))
        ),
        "Delta", [VDt2] - [VDt1]
    ),
    SWITCH(
        TRUE(),
        ISBLANK(_DeltaType), [VDt1],
        _DeltaType = "Decrease", IF([Delta] < 0, [VDt1], BLANK()),
        _DeltaType = "Increase", IF([Delta] > 0, [VDt1], BLANK()),
        [VDt1]
    )
)

 

@teefy 

 

You're welcome.

Greg_Deckler
Community Champion
Community Champion

@teefy You sort of have the reverse of this problem but this should show you the basics of how to get your DAX to calculate at a different level of granularity. Bottom line, the trick is to use ALL or ALLSELECTED to essentially remove the internal visual context filters and then you impose your own filter context back on the table.

Matrix Measure Total Triple Threat Rock & Roll - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.