Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi everyone,
I am trying to calculate Order Type, at looking at the items contained in that order. See example:
| Order Number | Item | Order Category |
| 1 | Applaince | Applaince |
| 1 | Refill | Applaince |
| 1 | Pack | Applaince |
| 2 | Pack | Pack |
| 2 | Tube | Pack |
| 3 | Refill | Refill |
| 3 | Refill | Refill |
| 3 | Pack | Refill |
| 4 | Pack | Pack |
Basically Appliance in any order takes priority, then Refill, then pack etc.
Can someone help?
Thanks a lot,
Filip
Solved! Go to Solution.
Hey @Anonymous ,
ah, now I get what you mean.
And how is the order? Is it always Appliance before Refill and that before Pack?
Then you could try the following approach. First I create a table with all rows for the current myTable[Order Number]. Then I check if this order contains "Apllaince" or "Refill" or "Pack". And then I return in Order either "Apllaince" or "Refill" or "Pack" if the table contains the value for the current order:
Order Cat =
VAR vMaxOrderNumber = MAX(myTable[Order Number])
VAR vFilteredTable = FILTER(ALL(myTable), myTable[Order Number] = vMaxOrderNumber)
VAR vApllaince = IF(CONTAINS(SUMMARIZE(vFilteredTable, myTable[Order Number], myTable[Item]), myTable[Item], "Applaince"), "Applaince")
VAR vRefill = IF(CONTAINS(SUMMARIZE(vFilteredTable, myTable[Order Number], myTable[Item]), myTable[Item], "Refill"), "Refill")
VAR vPack = IF(CONTAINS(SUMMARIZE(vFilteredTable, myTable[Order Number], myTable[Item]), myTable[Item], "Pack"), "Pack")
RETURN
SWITCH (
TRUE (),
vApllaince <> BLANK (), vApllaince,
vRefill <> BLANK (), vRefill,
vPack <> BLANK (), vPack
)
Hey @Anonymous ,
I didn't fully get the case.
What do you expect as a result? Can you do an example that I can understand how it should look like?
Best regards
Denis
Hi, I have the order number and the Item. i need to calculate the Order Category.
Hey @Anonymous ,
ah, now I get what you mean.
And how is the order? Is it always Appliance before Refill and that before Pack?
Then you could try the following approach. First I create a table with all rows for the current myTable[Order Number]. Then I check if this order contains "Apllaince" or "Refill" or "Pack". And then I return in Order either "Apllaince" or "Refill" or "Pack" if the table contains the value for the current order:
Order Cat =
VAR vMaxOrderNumber = MAX(myTable[Order Number])
VAR vFilteredTable = FILTER(ALL(myTable), myTable[Order Number] = vMaxOrderNumber)
VAR vApllaince = IF(CONTAINS(SUMMARIZE(vFilteredTable, myTable[Order Number], myTable[Item]), myTable[Item], "Applaince"), "Applaince")
VAR vRefill = IF(CONTAINS(SUMMARIZE(vFilteredTable, myTable[Order Number], myTable[Item]), myTable[Item], "Refill"), "Refill")
VAR vPack = IF(CONTAINS(SUMMARIZE(vFilteredTable, myTable[Order Number], myTable[Item]), myTable[Item], "Pack"), "Pack")
RETURN
SWITCH (
TRUE (),
vApllaince <> BLANK (), vApllaince,
vRefill <> BLANK (), vRefill,
vPack <> BLANK (), vPack
)
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 39 | |
| 37 | |
| 29 | |
| 24 |
| User | Count |
|---|---|
| 120 | |
| 95 | |
| 70 | |
| 69 | |
| 65 |