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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
pstaggers
Advocate II
Advocate II

Pros and Cons of 4 Different Running Total / Cumulative Calculations

I have found the following  4 ways to calculate a running total as a measure.  What are the pros and cons of each method?

 

pstaggers_0-1636135239927.png

 

Item Running Total1 =
VAR MaxDate = MAX ( 'Table'[Date] )
VAR Result =
CALCULATE(
SUM( 'Table'[Item] ),
'Table'[Date] <= MaxDate,
ALL ( 'Table'[Date] )
)
RETURN
Result
--------------------------------------------------------------
Item Running Total2 =
CALCULATE(
SUM('Table'[Item]),
FILTER(
ALL('Table'[Date]),
'Table'[Date] <= MAX('Table'[Date])
)
)
--------------------------------------------------------------
Item Running Total3 =
CALCULATE(
SUM('Table'[Item]),
DATESINPERIOD(
'Table'[Date],
MAX( 'Table'[Date] ),
-1000,
DAY
)
)
--------------------------------------------------------------
Item Running Total4 =
CALCULATE(
SUM('Table'[Item]),
FILTER(
ALLSELECTED('Table'[Date]),
ISONORAFTER('Table'[Date], MAX('Table'[Date]), DESC)
)
)
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@pstaggers 

There isn't any difference between those methods, the performance speeds are logically the same since they all  just comparing dates. Method 1 and Method 2 are the same, Method 1 just stores the MaxDate into a variable then use it in the return expression.

 

What's important is the different between using All(table) and Allselected(table). If you want to using filter or slicer on the the running total measure, you would need to using allselected() instead of just ALL(). For example:

Item Running Total2 =
CALCULATE(
SUM('Table'[Item]),
FILTER(
ALLSELECTED('Table'[Date]),
'Table'[Date] <= MAX('Table'[Date])))

 

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

@pstaggers 

There isn't any difference between those methods, the performance speeds are logically the same since they all  just comparing dates. Method 1 and Method 2 are the same, Method 1 just stores the MaxDate into a variable then use it in the return expression.

 

What's important is the different between using All(table) and Allselected(table). If you want to using filter or slicer on the the running total measure, you would need to using allselected() instead of just ALL(). For example:

Item Running Total2 =
CALCULATE(
SUM('Table'[Item]),
FILTER(
ALLSELECTED('Table'[Date]),
'Table'[Date] <= MAX('Table'[Date])))

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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