March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi
What’s the DAX code to create a measure that calculates the cumulative sum of another measure?
My data is something like following:
Customer | Sales | Rank | % of Total | Cumulative % |
A | 1000 | 1 | 33.3% | 33.3% |
B | 800 | 2 | 26.7% | 60.0% |
C | 500 | 3 | 16.7% | 76.7% |
D | 400 | 4 | 13.3% | 90.0% |
E | 300 | 5 | 10.0% | 100.0% |
Both “Rank” and “% of Total” are measures. Now I need to create another measure “Cumulative %” to sum up on the measure “% of total”.
Many examples I found are for the calculation of cumulative sum on columns, not measures, or the filter is on the column values. but here it seems I need to filter on a measure (Rank). How do you get that Rank # into your DAX code and then sum up on “% of Total”?
Thanks!
YL
Solved! Go to Solution.
Hi @ylin88_waters ,
Check the formula.
Measure = SUMX(FILTER(ALLSELECTED('Table'),[_rank]<=MAXX('Table',[_rank])),'Table'[_% of Total])
Best Regards,
Jay
Hi @ylin88_waters ,
Check the formula.
Measure = SUMX(FILTER(ALLSELECTED('Table'),[_rank]<=MAXX('Table',[_rank])),'Table'[_% of Total])
Best Regards,
Jay
Try this:
Cumulative % =
Var _R = [Rank]
Var _A = SUMMARIZE(all('Table'),'Table'[Customer],'Table'[Sales],"Rank",[Rank])
Var _B = filter(_A,[Rank]<=_R)
Var _C = SUMX(_B,[Sales])
return
_C/CALCULATE(sum('Table'[Sales]),all('Table'))
output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
@ylin88_waters try something like this:
**bleep** Sum =
VAR __rank = [Rank Measure]
RETURN SUMX ( FILTER( ALL ( 'Table' ), [Rank Measure] <= __rank ), [% Total] )
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi VahidDM & parry2k:
Thanks a lot for your help.
I tried both of your sample codes, but they didn't work. It seems the Dax didn't really capture the Rank (a measure) of current row. It actually calculated the sum of all rows. It seems I can't upload my testing file here(using 1000 rows of dummy data), so I just put an image of the result table.
=====================
If you see anything I need to change to make it work, le tme know. Thanks again.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
115 | |
76 | |
57 | |
52 | |
44 |
User | Count |
---|---|
164 | |
116 | |
63 | |
57 | |
50 |