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

Rank based on cumulative total

I have operation and values sequence and want to rank them if the cumulative sum of earlier is equal or less than 30.


Data set 

idoperationvalue
1op1 10
2op220
3op330
4op415
5op515
6op610


Expected Outcome

idoperationvaluecumulative valueRank
1op1 10101
2op220301
3op330302
4op415153
5op515303
6op610104

 

Thank you in advance.

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @pateam

create calculated columns

cumulative = CALCULATE(SUM(Table1[value]),FILTER(ALL(Table1),[id]<=EARLIER([id])))

int = INT(Table1[cumulative]/30)

earlier = LOOKUPVALUE(Table1[int],Table1[id],Table1[id]-1)

diff = Table1[int]-Table1[earlier]

group = IF(Table1[diff]=1,CALCULATE(SUM(Table1[diff]),FILTER(Table1,Table1[id]<=EARLIER(Table1[id]))),BLANK())

rank = IF(Table1[group]=BLANK(),CALCULATE(FIRSTNONBLANK(Table1[group],1),FILTER(Table1,Table1[id]>EARLIER(Table1[id]))),Table1[group])

4.png

 

If you have more values in this table, you would see all ranks. 

 

 

Best Regards

Maggie

Dear  

 

Dear Maggie,

 

Thank you very much. struggled few days on this.

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.

Top Solution Authors