Forum Discussion
Cumulative Sum
Morning,
I'm really struggling with creating a Cumulative total and not sure what I'm doing wrong. I've managed to create it previously but I couldn't get it to limit the values to this financial year (it was working the whole table) so I created a new table in DAX just bringing in the date periods I needed but now I can't get the running total to work.
Here's the code I'm using
Hoping someone can help with the date limiting element or just get the above code working. I've tried to attach screenshots and a sample of the data, there's nothing special about it.
| Date | Budget | Projection |
| 01-Feb-21 | 194.37 | 296.97 |
| 01-Feb-21 | 146.28 | 98.05 |
| 01-Feb-21 | 707.19 | 96.36 |
| 01-Feb-21 | 3683.07 | 1712.34 |
| 01-Feb-21 | 2034.12 | 2564.96 |
| 01-Mar-21 | 110.37 | 244.53 |
| 01-Mar-21 | 34327.02 | 11786.25 |
| 01-Mar-21 | 15110.45 | 5989.95 |
| 01-Mar-21 | 14410.2 | 24919.87 |
| 01-Mar-21 | 1223.43 | 1370.46 |
Hi, Anonymous
You can change the above measure like this:
Cumulative Sum = var _max = maxx(allselected(Cummlative),Cummlative[Date]) return CALCULATE ( sum(Sheet1[Budget]), FILTER ( ALLselected ( Sheet1), Sheet1[Date] <= MAX (Sheet1[Date] ) && Sheet1[Date] <=_max ) )And you can get what you want, like this:
You can download my test pbix file here
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- amitchandakSuper User
Anonymous , Try a measure like
Cumulative Sum =
var _max = maxx(allselected(sheet,sheet[Date]))
return
if( CALCULATE (
sum(Sheet1[Budget]),
FILTER (
ALLselected ( Sheet1),
Sheet1[Date] <= MAX (Sheet1[Date] )
&& Sheet1[Date] <=_max
)
)- AnonymousNot applicable
Thanks for the quick reply on this,
the MaxX is missing an expression - any ideas?Thanks.
- v-robertq-msftCommunity Support
Hi, Anonymous
You can change the above measure like this:
Cumulative Sum = var _max = maxx(allselected(Cummlative),Cummlative[Date]) return CALCULATE ( sum(Sheet1[Budget]), FILTER ( ALLselected ( Sheet1), Sheet1[Date] <= MAX (Sheet1[Date] ) && Sheet1[Date] <=_max ) )And you can get what you want, like this:
You can download my test pbix file here
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.