Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
78 | |
78 | |
59 | |
35 | |
33 |
User | Count |
---|---|
100 | |
62 | |
56 | |
47 | |
41 |