The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I am doing ABC analysis in Power BI which is mainly done for inventory management. I have followed the superb article- https://www.daxpatterns.com/abc-classification/ which fulfills my requirement of making the calculations dynamic based on the filters applied by the user.
I am now stuck with the presentation part which is to be shown as:
Consumption | |||||
A | B | C | D | ||
Stock | A | 2979 | 55 | 5 | 345 |
B | 12 | 33 | 7 | 0 | |
C | 1 | 1 | 5 | 1 | |
D | 6 | 1 | 3 | 0 |
I am not sure how to achieve.
I saw a similar article trying to do the same thing-https://community.fabric.microsoft.com/t5/Desktop/ABC-XYZ-dynamic-analysis-trouble-getting-both-an-A...
But, the solution is not very extensively given.
Can anyone help me here, please?
Here are the two measures I have used:
Dynamic_ABC STOCK Value =
VAR StockValuebymaterialNo =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( 'StockTable', 'StockTable'[Material No] ),
"@MatStock", [TOT_STOCK_VALUE]
),
ALLSELECTED ( 'StockTable' )
)
VAR ALLStockValue =
CALCULATE ( [TOT_STOCK_VALUE], ALLSELECTED ( 'StockTable' ) )
VAR CumulatedPctByMatStock =
ADDCOLUMNS (
StockValuebymaterialNo,
"@CumulatedStock%",
VAR CurrentStockValue = [@MatStock]
VAR CumulatedStock =
FILTER ( StockValuebymaterialNo, [@MatStock] >= CurrentStockValue )
VAR CumulatedStockValue =
SUMX ( CumulatedStock, [@MatStock] )
VAR Perc =
DIVIDE ( CumulatedStockValue, ALLStockValue )
RETURN
MIN ( Perc, 1 ) -- Avoid >100% in case of rounding issues
)
VAR MatInClass =
FILTER (
CROSSJOIN ( CumulatedPctByMatStock, 'ABC Classes' ),
AND (
[@CumulatedStock%] > 'ABC Classes'[Lower Boundary],
[@CumulatedStock%] <= 'ABC Classes'[Upper Boundary]
)
)
VAR Result =
CALCULATE (
[TOT_STOCK_VALUE],
KEEPFILTERS ( MatInClass )
)
RETURN
Result
Dynamic_ABC Consumption Value =
VAR ConsumptionValuebymaterialNo =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( 'ConsumptionTable', 'ConsumptionTable'[Material No] ),
"@MatConsumption", [AverageDailyConsumption]
),
ALLSELECTED ( 'ConsumptionTable' )
)
VAR ALLConsumptionValue =
CALCULATE ( [AverageDailyConsumption], ALLSELECTED ( 'ConsumptionTable' ) )
VAR CumulatedPctByMat =
ADDCOLUMNS (
ConsumptionValuebymaterialNo,
"@Cumulated%",
VAR CurrentConsumptionValue = [@MatConsumption]
VAR CumulatedConsumption =
FILTER ( ConsumptionValuebymaterialNo, [@MatConsumption] >= CurrentConsumptionValue )
VAR CumulatedConsumptionValue =
SUMX ( CumulatedConsumption, [@MatConsumption] )
VAR Perc =
DIVIDE ( CumulatedConsumptionValue, ALLConsumptionValue )
RETURN
MIN ( Perc, 1 ) -- Avoid >100% in case of rounding issues
)
VAR MatInClass =
FILTER (
CROSSJOIN ( CumulatedPctByMat, 'ABC Classes' ),
AND (
[@Cumulated%] > 'ABC Classes'[Lower Boundary],
[@Cumulated%] <= 'ABC Classes'[Upper Boundary]
)
)
VAR Result =
CALCULATE (
[AverageDailyConsumption],
KEEPFILTERS ( MatInClass )
)
RETURN
Result
User | Count |
---|---|
11 | |
8 | |
6 | |
6 | |
5 |
User | Count |
---|---|
24 | |
14 | |
13 | |
9 | |
8 |