Forum Discussion

PC2790's avatar
PC2790
Icon for Community Champion rankCommunity Champion
3 years ago

Help needed with pivot based on dynamic categories for ABC analysis

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 from Stock & Consumption.

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

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

2) Calculate Cumulative stock value based on ranking in descending order starting from maximum stock value calculated in step 1(my problem lies here)

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

4)

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 change based on the filters applied(filter are page level filters). 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 create a pivot that can have A,B,C and D categories of stock and A,B,C and D categories of stock as rows and columns and based on that the values extracted based on stock value and stock consumption can be provided in that pivot.

Something shown below:

 

providing the sample data  and the calculations expected for reference

Ashish_Mathur amitchandak  Will you be able to provide some assistance here please?

4 Replies