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
PC2790
Community Champion
Community Champion

Calculation of dynamic values based on ranking

Hi,

 

I have a scenario as part of which I want to create a pivot in Power BI based on Categories-A,B,C and D.

The calculation of A,B,C and D is as follows:

1)Total Stock which is a measure:  Stock Value = 'Table'[Stock_Qty] * 'Table'[Net Price] 

2) Calculate Cumulative stock value based on ranking(my problem lies here)

2) Stock% = Cumulative stock Value/ Total Stock(should be based on filters applied)

 

ABCD Category =
SWITCH(TRUE(),
[Stock% ] < 0.7 || [ADC %] = 0.7 ,"A",
[Stock%] < 0.85 || [ADC %] = 0.85 ,"B",
[Stock%] < 0.95 || [ADC %] = 0.95 , "C",
[Stock%] < 1.00 || [ADC %] = 1.00 , "D",
0)
Now the problem here is that the cumulative stock value is to be calculated on the basis of ranking in descending order.
And the ranking should be dynamic and should changes based on the filters applied. 
I used Rankx function based on Item ID form my Stock table, but that will only work if my ITEM ID is in cope of the visual, what if the end user, removes item id and adds region to it or Type to it. The rank will not work and hence the subsequent steps as well.
Is there any way to get the rank dynamically based on which the stock% and category is selected? 
2 REPLIES 2
johnyip
Solution Sage
Solution Sage

Can you provide some sample data and the visual format you are using?

From your description, the issue seems to be solvable by SUMMARIZE() / CALCULAETABLE() / etc



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!
PC2790
Community Champion
Community Champion

File with sample data attached here

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.