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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Rolling total not working for delta calculated by measure

Hi all,

 

I have the following measure which calculates the delta of the average value of last quarter and the average value of the qurrent quarter. The table contains the value per day, and needs to be averaged by quarter.

 

ValueDelta =

VAR CURRENTQ = AVERAGE(Table[Value])

VAR PREVQ = CALCULATE(AVERAGE(Table[Value]),PREVIOUSQUARTER(DateTable[Date]))

 

RETURN

IF(ISBLANK(PREVQ) || ISBLANK(CURRENTQ),BLANK(),

ABS(PREVQ - CURRENTQ)

)

 

Resulting in the following metrics:

 

YearQuarterValueDelta
20221970
202221.603
20223946
20224920
202311.073
202321.341
20233915
20234920

 

Now I'd like to calculate the rolling total for 'ValueDelta' like this:

 

YearQuarterValueDeltaRolling total
20221970 
202221.6032.573
202239463.519
202249204.439
202311.0735.512
202321.3416.853
202339157.768
202349208.688

 

I've tried multiple suggestions online like:
https://community.powerbi.com/t5/Desktop/Cumulative-Total/td-p/43115
https://www.daxpatterns.com/cumulative-total/ 

https://www.sqlbi.com/articles/computing-running-totals-in-dax/

 

For me these just return the same 'ValueDelta' value or blanks.

 

Any ideas or directions would be very helpful!

Thanks in advance.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try a measure like

 

calculate(sumx(values(DateTable[Year Qtr]),[ValueDelta]), filter(AllSelected(DateTable), DateTable[Date]<=max(DateTable[Date])))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try a measure like

 

calculate(sumx(values(DateTable[Year Qtr]),[ValueDelta]), filter(AllSelected(DateTable), DateTable[Date]<=max(DateTable[Date])))

Anonymous
Not applicable

This works! thank you so much, was really struggling. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors