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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Difference in cummulative total

Hi DAX experts,

I currently have this measure that calculates running total for payment based on date

Total Running Payment = 
VAR MaxDate = MAX ( 'Balance'[new_date] ) 
RETURN
    CALCULATE (
        [Total Payment Amount],            
        'Balance'[new_date] <= MaxDate,   
        ALL ( Balance )               
    )

How do I proceed to find the differences between running total? I tried out several solutions posted in the forum but wasnt able to get it working. I would really appreciate for your input. Thanks!

1 ACCEPTED SOLUTION
edhans
Super User
Super User

You will need to find out the next to last date. So your variable 

VAR MaxDate = MAX ( 'Balance'[new_date] )

 is fine. You can use that as follows:

VAR varMaxDate =
    MAX( Dates[Date] )
VAR varNextToMaxDate =
    MAXX(
        FILTER(
            ALL( Dates[Date] ),
            Dates[Date] < varMaxDate
        ),
        Dates[Date]
    )

So in my little sample table, varMaxDate is April 1, and varNextToMaxDate is March 15. You can then use the varNextToMaxDate to calculate the previous total.

 
 
 
 

2020-07-29 09_53_12-Untitled - Power BI Desktop.png

So perhaps another variable that calculates that previous total, then just do the math: varMaxValue - varPreviousDateValue.

    CALCULATE (
        [Total Payment Amount],            
        'Balance'[new_date] = varNextToMaxDate,   
        ALL ( Balance )               
    )
 

But I'd need to see some data to tinker with the filtering. I think your ALL() statement takes care of that but you'd need to test.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

4 REPLIES 4
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

You can also try this since you are using time intelligence and a date table.

 

Running Total = 
VAR MaxDate = MAX ( 'Dates'[Date] ) 
RETURN
    CALCULATE (
        [Total Sales],           
        'Dates'[Date] <= MaxDate,   
        ALL ( Dates )               
    )

 

Running Total-1 = 
VAR MaxDate = MAX ( 'Dates'[Date] ) - 1 
RETURN
    CALCULATE (
        [Total Sales],           
        'Dates'[Date] <= MaxDate,   
        ALL ( Dates )               
    )

 

Difference RT = [Running Total] - [Running Total-1]

 

 

1.jpg

 

 

 

Regards,
Harsh Nathani

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

edhans
Super User
Super User

You will need to find out the next to last date. So your variable 

VAR MaxDate = MAX ( 'Balance'[new_date] )

 is fine. You can use that as follows:

VAR varMaxDate =
    MAX( Dates[Date] )
VAR varNextToMaxDate =
    MAXX(
        FILTER(
            ALL( Dates[Date] ),
            Dates[Date] < varMaxDate
        ),
        Dates[Date]
    )

So in my little sample table, varMaxDate is April 1, and varNextToMaxDate is March 15. You can then use the varNextToMaxDate to calculate the previous total.

 
 
 
 

2020-07-29 09_53_12-Untitled - Power BI Desktop.png

So perhaps another variable that calculates that previous total, then just do the math: varMaxValue - varPreviousDateValue.

    CALCULATE (
        [Total Payment Amount],            
        'Balance'[new_date] = varNextToMaxDate,   
        ALL ( Balance )               
    )
 

But I'd need to see some data to tinker with the filtering. I think your ALL() statement takes care of that but you'd need to test.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
amitchandak
Super User
Super User

@Anonymous , difference between what?

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
Anonymous
Not applicable

Hi @amitchandak,

Thanks for responding. I want to find the difference in running total in two consecutive dates

pic.PNG

So for 3/31/20, the difference would be between 773,541,925 and 773,087,384; for 3/30/20 the difference would be between 773,087,386 and 772,220,532; etc.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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