Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
longpham03
Regular Visitor

Cumulative sum of a measure

Hi all,

 

I have 3 tables:

Sales table has 3 columns: Date, PartNo, Amount

DateTable

Part table has 2 columns: PartNo, PartName

 

I have this measure to calculate the semi annual sales:

SemiAnnualSales = CALCULATE(SUM(Sales[Amount]),DATESINPERIOD(DateTable[Date],LASTDATE(DateTable[Date]),-6,MONTH))

 

 

 

And this mesure to calculate share:

 

 

Share = DIVIDE([SemiAnnualSales],CALCULATE([SemiAnnualSales],ALL(Parts)))

 

My goal is to calculate cummulative share based and ranked by [Share]. I have difficulty because [Share] is a measure.

 

This is the result I want. Please help!!! Any input is greatly appreciated.

 

PartNoSemiAnnualSalesShareCummulativeShare
08F60-KVG-740A19214%14%
08F60-KVG-710B18013%27%
08F60-KVG-720B15111%37%
08F60-KVG-750A1319%47%
08F60-KVG-710A1259%56%
08F60-KVG-720A967%62%
08F62-KWW-710A957%69%
08F63-KVG-740A947%76%
08F60-KVG-730B916%82%
08F60-KVG-740B846%88%
08F60-KVG-730A624%93%
08F63-KVG-730B614%97%
08F63-KVG-740B403%100%
08F60-KVG-750B00%100%
1 ACCEPTED SOLUTION
v-diye-msft
Community Support
Community Support

Hi @longpham03 

 

Add the rank measure as index:

Measureindex = RANKX(ALLSELECTED('Table'),[MeasureShare],,DESC)

Then calculate the cumulative sum:

Measure = 
var t = ADDCOLUMNS(ALLSELECTED('Table'[PartNo]),"A",[MeasureShare],"B",[Measureindex])
var a = [Measureindex]
return
SUMX(FILTER(t,[Measureindex]<=a),[MeasureShare])

001.PNG

Community Support Team _ Dina Ye
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
v-diye-msft
Community Support
Community Support

Hi @longpham03 

 

Add the rank measure as index:

Measureindex = RANKX(ALLSELECTED('Table'),[MeasureShare],,DESC)

Then calculate the cumulative sum:

Measure = 
var t = ADDCOLUMNS(ALLSELECTED('Table'[PartNo]),"A",[MeasureShare],"B",[Measureindex])
var a = [Measureindex]
return
SUMX(FILTER(t,[Measureindex]<=a),[MeasureShare])

001.PNG

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
amitchandak
Super User
Super User

@longpham03 , In the quick measure you have an option for running total, Try that.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for your help. I was able to choose [Share] for "Base Value", but I couldn't choose [Share] for "Field". I need [Share] to be the running field, DESC.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.