Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Hi everyone,
I'm trying to perform an ABC Analysis.
I have three tables:
ITEMS[ID, Description],
STOCKS[Item, Stock_qty],
SALES[Item, Value].
SALES[Item]and STOCKS[Item] are both linked to ITEMS[ID].
I built a measure to calculate the average:
Average stock = AVERAGE(STOCKS[Stock_qty])
The following code calculates the class A, B, C or D for every item in ITEMS table:
ABC Warehouse =
VAR T1 = SUMMARIZE(ALL(ITEMS), ITMES[ID], "QTY", [Average Stock])
VAR T2 = ADDCOLUMNS(T1, "QTY_CUMULATED", SUMX(FILTER(T1, [QTY] >= EARLIER([QTY])), [QTY]))
VAR QTY_TOT = SUMX(ALL(ITEMS), [Average Stock])
VAR T3 = ADDCOLUMNS(T2, "PRC", DIVIDE([QTY_CUMULATED], QTY_TOT, 0))
VAR T4 = ADDCOLUMNS(T3, "ABC", SWITCH(TRUE(), [PRC] <= 0.8, "A", [PRC] <= 0.95, "B", [QTY] <> 0, "C", "D"))
VAR T5 = FILTER(T4, ITEMS[ID] = MAX(ITEMS[ID]))
RETURN MAXX(T5, [ABC])
There are althought items that i wanna remove, before doing this calculation. There are items that have a SALES[Value] equal to zero. So, i want to remove them with a filter. I tried many ways but i don't know how to get the right result.
In other words i want the table in ALL function in var T1 and in var QTY_TOT to NOT have items that have SALES[Value] equal to zero.
Thanks
@Veigar
Can you replace the 3rd line with the following:
var QTY_TOT = SUMX(FILTER(ALL(ITEMS), calculate(sum(SALES[Value])) <> 0), [Average Stock])
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hi @Fowmy ,
Thanks for your answer.
The measure is wrong, because now it shows that there are 80% of items in class A, while before there where around 20%. I managed to do it in another way, but i'm still interested in this solution, i'll try to modify it.
But i saw that this solution is very slow, i have to manage around 7000 items.
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 22 | |
| 22 | |
| 18 | |
| 17 | |
| 13 |
| User | Count |
|---|---|
| 63 | |
| 50 | |
| 46 | |
| 41 | |
| 39 |