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

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

Cumulative Sum =
     CALCULATE (
     sum(Sheet1[Budget]),
          FILTER (
          ALL ( Sheet1[Date].[Date]),
          Sheet1[Date].[Date] <= MAX (cummlative[Date].[Date] )
)
)


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.
 
Cum1.PNGCum2.PNG
DateBudgetProjection
01-Feb-21194.37296.97
01-Feb-21146.2898.05
01-Feb-21707.1996.36
01-Feb-213683.071712.34
01-Feb-212034.122564.96
01-Mar-21110.37244.53
01-Mar-2134327.0211786.25
01-Mar-2115110.455989.95
01-Mar-2114410.224919.87
01-Mar-211223.431370.46
1 ACCEPTED SOLUTION

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:

屏幕截图 2020-10-28 103105.png

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.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super 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
)
)

Anonymous
Not applicable

Thanks for the quick reply on this,

the MaxX is missing an expression - any ideas?

 

Thanks.

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:

屏幕截图 2020-10-28 103105.png

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.

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.