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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.