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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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