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
kleetus51
Frequent Visitor

Cumulative sum based on rank and category

I have a dataset that ranks all values by a KPI category. I'd like to add a Cumulative column that sums all values that rank at or below the current record in the same category. How would I calulate the data to get the results in the last column below?

KPIRankValueCumulative Value
GM $1$4,979$31,968
GM $2$4,586$26,989
GM $3$4,460$22,403
GM $4$3,439$17,943
GM $5$3,405$14,504
GM $6$3,293$11,099
GM $7$2,716$7,806
GM $8$1,400$5,090
GM $9$1,190$3,690
GM $10$712$2,500
GM $11$617$1,788
GM $12$611$1,171
GM $13$307$560
GM $14$253$253
Sales $1$8,769$51,412
Sales $2$6,949$42,643
Sales $3$6,770$35,694
Sales $4$6,256$28,924
Sales $5$5,712$22,668
Sales $6$4,897$16,956
Sales $7$4,818$12,059
Sales $8$3,972$7,241
Sales $9$1,716$3,269
Sales $10$1,553$1,553
1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

ColumnN = var _kpi = TableF[KPI]
var _rank = TableF[Rank]
RETURN
CALCULATE(SUM(TableF[Value]), FILTER(TableF, TableF[KPI] = _kpi && TableF[Rank] >= _rank))

as a column

View solution in original post

2 REPLIES 2
HotChilli
Super User
Super User

ColumnN = var _kpi = TableF[KPI]
var _rank = TableF[Rank]
RETURN
CALCULATE(SUM(TableF[Value]), FILTER(TableF, TableF[KPI] = _kpi && TableF[Rank] >= _rank))

as a column

Works great, thanks!

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.