Forum Discussion
Cumulative Total
- 10 years ago
ElliotP Sorry about the original post. It was from my phone and had typos :smileywink:
Okay here is the formula for Running Total as a Calculated Column (prorerly formatted)
Running Total COLUMN = CALCULATE ( SUM ( 'All Web Site Data (2)'[UniquePageviews] ), ALL ( 'All Web Site Data (2)' ), 'All Web Site Data (2)'[Date] <= EARLIER ( 'All Web Site Data (2)'[Date] ) )And as you can see it works! :smileyhappy:
And here's the MEASURE formula
Running Total MEASURE = CALCULATE ( SUM ( 'All Web Site Data (2)'[UniquePageviews] ), FILTER ( ALL ( 'All Web Site Data (2)' ), 'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] ) ) )Which also works...
For a calculated column :
CumulativeQuantity2 =
VAR CURRENTDATE='All Web Site Data (2) '[Date]
RETURN
CALCULATE(SUM('All Web Site Data (2) '[UniquePagePreviews]);FILTER(all('All Web Site Data (2)');'All Web Site Data (2) '[Date]<= CURRENTDATE))
For a measure:
CumulativeQuantity-M =
CALCULATE(SUM('All Web Site Data (2) '[UniquePagePreviews]);FILTER(all('All Web Site Data (2) ');'All Web Site Data (2) '[Date]<= MAX('All Web Site Data (2) '[Date])))
I hope this help you.
ElliotP Sorry about the original post. It was from my phone and had typos :smileywink:
Okay here is the formula for Running Total as a Calculated Column (prorerly formatted)
Running Total COLUMN =
CALCULATE (
SUM ( 'All Web Site Data (2)'[UniquePageviews] ),
ALL ( 'All Web Site Data (2)' ),
'All Web Site Data (2)'[Date] <= EARLIER ( 'All Web Site Data (2)'[Date] )
)
And as you can see it works! :smileyhappy:
And here's the MEASURE formula
Running Total MEASURE =
CALCULATE (
SUM ( 'All Web Site Data (2)'[UniquePageviews] ),
FILTER (
ALL ( 'All Web Site Data (2)' ),
'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] )
)
)
Which also works...
- tameemyousaf8 years agoHelper I
Sean What if we have multiple rows for same date?
- ElliotP10 years agoPost Prodigy
Thank you so much guys, I really appreciate it. It has been doing my head in.
Why do we use the filter feature for the measure but not the column? I checked and the measure formula works for a new column as well, but I'm curious as to explanation of the difference.
As well, I know this is going to be all the more complicated; But I'd also like to calculate a moving and trailing average. I'll have a try myself again, but if either Sean or Vvelarde knows the forumla off the top of their head, that would be greatly appreciated.
Thank you so much.- Sean10 years agoCommunity Champion
ElliotP Okay since you didn't mention how many Days or Month Average
Try this...
Moving Average = DIVIDE ( CALCULATE ( SUM ( 'All Web Site Data (2)'[UniquePageviews] ), FILTER ( ALL ( 'All Web Site Data (2)' ), 'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] ) ) ), CALCULATE ( DISTINCTCOUNT ( 'All Web Site Data (2)'[Date] ), FILTER ( ALL ( 'All Web Site Data (2)' ), 'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] ) ) ), 0 )The Numerator is basically your Running Total Measure (so you actually can use the Measure name there) while
The Denominator is the number of days.
See picture to see how formula works :smileyhappy:
- ElliotP10 years agoPost Prodigy
Thanks for the quick and explained reponse. I recieved the same thing; excep the Moving average values is the value for example for day 5 of 100, simply divided by 5 = 20. As opposed to being a running total divided by the number of days.
Something like
Day 1: 10
Day 2: 20
Day 3: 30
Day1avg: 10
Day2avg: 15
Day3avg: 20
I'll try and work it out, I'm trying to use the DATESBETWEEN function and some of the previousmonth and dateadd functions but I'm currently being told there are too few arguements (another issue).
- rparthasarathy9 years agoRegular Visitor
If i have a continuos data of the above kind, how will i calculate the culmative sum based on Month, Quarter and Year.
Thanks,
Raaghavan - AliceW5 years agoPower Participant
Thank you so much for the formula!
I made an adjustment so that various filters applied in the page would work: instead of ALL(), i've used ALLSELECTED([Date]).
- neilcotton4 years agoFrequent Visitor
Alice, you are a life saver. I've been trying to figure this out for 2 days.
Regards
Neil
- AliceW4 years agoPower Participant
Happy to help, Neil!
- Jpanz3 years agoFrequent Visitor
I had trouble with this formula, and the issue was the ALL() statement required my date column again. Shout out to this website for showing me.
https://powerbidocs.com/2020/11/08/cumulative-total-running-total-in-power-bi/
Running Total MEASURE = CALCULATE ( SUM ( 'All Web Site Data (2)'[UniquePageviews] ), FILTER ( ALL ( 'All Web Site Data (2)'[Date] ), 'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] ) ) )- IAM3 years agoHelper III
Thanks, I needed this!
- Rajiv12379 years agoResolver I
Doesn't work in Direct query mode of PowerBI
- Anonymous9 years agoNot applicable
What is the workaround for it then?
Cumulative Scheduled Quantity = CALCULATE(SUM(F_PROJECT_PROGRESS_WORKMEN[Scheduled_QTY]),FILTER(ALL(D_DATE[Date_Key]),D_DATE[Date_Key]>=DATE(YEAR(TODAY()),MONTH(TODAY()),1) && D_DATE[Date_Key]<=[Today's Date]))
Cumulative Actual Quantity = CALCULATE(SUM(F_PROJECT_PROGRESS_WORKMEN[Actual_QTY]),FILTER(ALL(D_DATE[Date_Key]),D_DATE[Date_Key]>=DATE(YEAR(TODAY()),MONTH(TODAY()),1) && D_DATE[Date_Key]<=[Today's Date]))
These are the measures I created as I can't create Columns in Direct query mode. I didn't get the error you got though, unless I am misinformed on something here.
- Rajiv12379 years agoResolver I
1. Its Direct Query Mode (Live connection with SQL) not loaded the data in Power BI
2. Filter cannot be used in Direct Query Mode.
3. I have written this formula for measure not for column
My Question is:
I can't find a way to calculate a running total, without using FILTER. Filter is not supported in PowerBi direct query-mode.
All help is appreciated
Not supported in Direct Query Mode

Running Total in DAX = CALCULATE( SUM('Table'[QTY]),
FILTER(
ALLSelected('Table'),
'Table'[Date] <= MAX('Table'[Date])
)
)
- Anonymous9 years agoNot applicable
You are a LIFE SAVER. I've been googling for an hour and none of it was put as simply as you did. Thank you!
- zq9 years agoFrequent Visitor
Hi there, I want to create a Running Difference instead of the Running Total (Sum) in POWER BI Table. Can you please guide how to achieve this?
- koenmilt8 years agoFrequent Visitor
Hi,
I tried the measure stated in the chosen solution (by Sean). This works!
My measure is as follows:
Cumulative Hours spend =
CALCULATE (
sum('OVERUREN_WEEK'[Hours Spend]);
FILTER (
ALL ('OVERUREN_WEEK'[Year_Week]);
'OVERUREN_WEEK'[Year_Week] <= MAX ( 'OVERUREN_WEEK'[Year_Week )
) )In my report I want to have a table visual that has three attibutes/columns, being: Year_week, Cost_center and Employee.
With the current DAX, the cumulative kinda works, it is cumulative by year_week, and breaks by all other attributes in the table visual (so Cost_center and Employee).
However, I only want it to break by Employee, it should keep cumulate when an employee switches cost_center.
Example:
Employee - cost center - function - year_week - hours spend - cumulative
Henk - 2500 - Developer - 201701 - 3 - 3
Henk - 2500 - Developer - 201702 - 1 - 4
Henk - 4000 - Developer - 201703 - 2 - 2
The cumulative restarts when the employee switches to a different Cost_center in week 201703.
The only way I was able to resolve was by removing Cost_Center from the table, But I dont want to do that.
- harrisonp788 years agoNew Member
Hi,
I am trying to do something similar to this - a 12 month rolling sum of sales that I can then show by month (ie september'17 will show october'16-september'17, october'17 will show november'16 - october'17, etc). I have managed to get this to work by modifying the formula in post 2. However, when using this, no filters work on my data - If I try to filter by product, customer gender, sales office, the numbers do not move. I have tried numerous filter variations but simply cannot get this to work. Can anyone offer any suggestions?
P