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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Cannot compute a cumulated value based on a dynamic index measure (not a column)

Hello everyone,

I hope you are well, I will be really grateful for the person who can help me !

Let's consider the following data :

table : item (sample)

Item_DescDateQuantityUnit_CostInventory_Value
01591A | item305/01/2022157155715
01591A | item313/01/2022-25715-11430
01591A | item302/02/20223571517145
01591A | item303/02/2022-211430-11430
01591A | item308/02/2022-25715-11430
01591A | item310/02/202241143022860
01591A | item316/02/2022-111430-5715
01591A | item322/02/202221143011430
01591A | item323/02/2022-25715-11430
01591A | item302/03/20223571517145
01464D | item104/03/20220632,50
01464D | item108/03/2022-21265-1265
01591A | item308/03/20223571517145
01591A | item316/03/20223571517145
02161A | item418/03/202259135,23977979
02161A | item422/03/2022-2270,4794-270
02161A | item423/03/2022-2270,4794-270
02161A | item424/03/2022-2135,2397-270
02161A | item428/03/2022-3135,2397-406
01591A | item330/03/20223571517145
02161A | item401/04/2022-2135,2397-270
01591A | item304/04/20223571517145
021612A | item405/04/2022-2135,2397-270
02221B | item505/04/202229220,97916408
01464D | item106/04/2022-21265-1265
02161A | item406/04/2022-2135,2397-270
02221B | item506/04/202229220,97916408
01464D | item107/04/202241126525933
01591A | item307/04/2022-25715-11430
02161A | item407/04/2022-5135,2397-676
02161A | item411/04/2022-4135,2397-541
01591A | item312/04/20223571517145
02161A | item412/04/2022-2135,2397-270
02161A | item414/04/2022-3135,2397-406
02221B | item514/04/2022-2220,9791-442
02221B | item515/04/2022-2441,9582-442
02161A | item419/04/2022-2135,2397-270
02221B | item520/04/2022-2220,9791-442
02161A | item422/04/2022-2135,2397-270
01464D | item126/04/2022-21265-1265
02161A | item426/04/2022-5270,4794-676
02161A | item427/04/2022-2270,4794-270
02161A | item428/04/202299135,239713389
022219B | item528/04/2022-2441,9582-442
01591A | item329/04/2022-211430-11430
...............

schema associated

Mohamed_59_0-1660924512582.png

The dynamic index is obtained by the following measure :

Dynamic index =
VAR _index = RANKX(ALLSELECTED('Item'[Item_Desc]),calculate(SUM('Item'[Inventory_Value])),,DESC,DENSE)
return
_index

 

What I want is to compute for each row the cumulated "Inventory_Value" based on the measure "dynamic_index" .

Results expected 

This will enable me to know dynamically (by switching between YearMonth) which items represent 80% of the total "Inventory_Value".

Thank you

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You don't need the dynamic index for that.  All you need to do is accumulate all values that are bigger or equal to the current value.

Cumul = 
var a = sum('Item'[Inventory_Value])
var b = CALCULATETABLE(SUMMARIZE('Item','Item'[Item_Desc],"s",sum('Item'[Inventory_Value])),ALLSELECTED())
var c = filter(b,[s]>=a)
return sumx(c,[s])

and you can do the percentage the same way

Cumul % = 
var a = sum('Item'[Inventory_Value])
var b = CALCULATETABLE(SUMMARIZE('Item','Item'[Item_Desc],"s",sum('Item'[Inventory_Value])),ALLSELECTED())
var c = filter(b,[s]>=a)
return divide(sumx(c,[s]),sumx(b,[s]),0)

 

lbendlin_0-1661218603770.png

 

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

You don't need the dynamic index for that.  All you need to do is accumulate all values that are bigger or equal to the current value.

Cumul = 
var a = sum('Item'[Inventory_Value])
var b = CALCULATETABLE(SUMMARIZE('Item','Item'[Item_Desc],"s",sum('Item'[Inventory_Value])),ALLSELECTED())
var c = filter(b,[s]>=a)
return sumx(c,[s])

and you can do the percentage the same way

Cumul % = 
var a = sum('Item'[Inventory_Value])
var b = CALCULATETABLE(SUMMARIZE('Item','Item'[Item_Desc],"s",sum('Item'[Inventory_Value])),ALLSELECTED())
var c = filter(b,[s]>=a)
return divide(sumx(c,[s]),sumx(b,[s]),0)

 

lbendlin_0-1661218603770.png

 

Anonymous
Not applicable

Oh my god, that's so amazing! This code is so elegant and helps me solve the dynamic Pareto problem on the sub-category!!!!

Anonymous
Not applicable

To implement real-time filtering out of the Pareto sub-category on category, you only need to do the following operations.

Cumul % = 
var a = sum('Item'[Inventory_Value])
var b = CALCULATETABLE(SUMMARIZE('Item','Item'[Item_Desc],"s",sum('Item'[Inventory_Value]),REMOVEFILTERS('Item'[Sub_Category]))
var c = filter(b,[s]>=a)
return
divide(sumx(c,[s]),sumx(b,[s]),0)
Anonymous
Not applicable

Thank you very much !

 

It works well for me.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.