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! Learn more

Reply
Anonymous
Not applicable

DAX Measure to calculate the difference in cumulative within the same column

Hello All,

I have the following table with the Cumulative Amounts split across Dates and Type and I want to calculate the amounts in between dates.

For Example: Between 6/27 and 7/25, the amount that was shipped was 35 (721-685) for Type=PF1. Also since 5/30 is the first date in the table, the cumulative amount = Desired Measure

 

Untitled.png

 

How do I do this in DAX?

I tried using EARLIER but since the dates do not increment by 1 every time, I'm not getting the desired amount

 

 

=
VAR CumulativeAmountPreviousDate =
CALCULATE (
SUM ( 'Table'[CumulativeAmount] ),
FILTER (
ALL ( 'Table' ),
'Table'[Date]
= EARLIER ( 'Table'[Date] ) - 1
&& 'Table'[Type] = EARLIER ( 'Table'[Type] )
)
)

RETURN
'Table'[CumulativeAmount] - CumulativeAmountPreviousDate

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

 

=Data[Cumulative amount]-LOOKUPVALUE(Data[Cumulative amount],Data[Date],CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Type]=EARLIER(Data[Type])&&Data[Date]<EARLIER(Data[Date]))),Data[Type],Data[Type])

 

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

 

=Data[Cumulative amount]-LOOKUPVALUE(Data[Cumulative amount],Data[Date],CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Type]=EARLIER(Data[Type])&&Data[Date]<EARLIER(Data[Date]))),Data[Type],Data[Type])

 

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

I tried your solution but I'm getting this error

 

Calculation error in column '[]: A table of multiple values was supplied where a single value was expected.

Well then you obviously have cases where the same Date and Type combination repeats.  Share a representative dataset and show the expetced result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

You were absolutely right. I grouped them by data and type and your formula worked! Thanks a lot!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.

Top Solution Authors