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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mberndt
Regular Visitor

DAX help

Hi guys,

 
I would like to ask you to help me out with this problem.
I would like to calculate a value in period t and then i would like to substract value in period t-1 from it. (value [t] - value [t-1]). 
 
Fallout_count_t-1 =
CALCULATE (
    SUM ( NC_FALLOUT_TREND_DATA[FALLOUT_COUNT] ),
    FILTER ( 'NC_FALLOUT_TREND_DATA', MAX ( [ITERATION] ) )
)
CALCULATE (
        SUM ( NC_FALLOUT_TREND_DATA[FALLOUT_COUNT] ),
        FILTER ( 'NC_FALLOUT_TREND_DATA', MAX ( [ITERATION] ) - 1 )
    )
 
Iteration is a whole number and I don't have a date in the table. I can't calculate t-1 value but it works if I just calculate MAX([ITERATION]) and MAX([ITERATION])-1 separately. So for MAX([ITERATION]) and MAX([ITERATION])-1 I get the right number, but it doesn't work in the calculate function. It brings 0 as a result for the substraction, because it calculates only the MAX ITERATION value somehow and not MAX([ITERATION])-1 in the second part of the substraction.
 
Thank you in advance for your replies!
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@mberndt , for all such case you you should have seperate table ITERATION or period and Try like

Assumsing  [ITERATION]  is column not measure

CALCULATE (
        SUM ( NC_FALLOUT_TREND_DATA[FALLOUT_COUNT] ),
        FILTER ( 'ITERATION',  [ITERATION]  = MAX ( [ITERATION] )  )
    )

 

CALCULATE (
        SUM ( NC_FALLOUT_TREND_DATA[FALLOUT_COUNT] ),
        FILTER (all( 'ITERATION'),  [ITERATION]  = MAX ( [ITERATION] ) - 1 )
    )

 

similar approach what I use for the week

 

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@mberndt , for all such case you you should have seperate table ITERATION or period and Try like

Assumsing  [ITERATION]  is column not measure

CALCULATE (
        SUM ( NC_FALLOUT_TREND_DATA[FALLOUT_COUNT] ),
        FILTER ( 'ITERATION',  [ITERATION]  = MAX ( [ITERATION] )  )
    )

 

CALCULATE (
        SUM ( NC_FALLOUT_TREND_DATA[FALLOUT_COUNT] ),
        FILTER (all( 'ITERATION'),  [ITERATION]  = MAX ( [ITERATION] ) - 1 )
    )

 

similar approach what I use for the week

 

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Thank you for your reply!

I created a dimension table for Iteration as you mentioned it with Enter data and made the relationship between the two tables. I changed the meassure exactly how you wrote it but still have a problem. Currently it returns the fallout count value of the latest (== max iteration) iteration. So as the result of the substraction I get only the value [t] and not value [t] - value [t-1].

Can you please help? Thank you in advance!

@mberndt , hope for t-1 you are using all in filter like -all( 'ITERATION')

Because if "t" is selected, then you will not get t-1

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak I am sorry, it works well right now... Thank you for your quick replies, really appreciated!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.