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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Determine Order Type by order contents

Hi everyone, 

 

I am trying to calculate Order Type, at looking at the items contained in that order. See example: 

 

Order NumberItemOrder Category
1ApplainceApplaince
1RefillApplaince
1PackApplaince
2PackPack
2TubePack
3RefillRefill
3RefillRefill
3PackRefill
4PackPack

 

Basically Appliance in any order takes priority, then Refill, then pack etc.

 

Can someone help? 

 

Thanks a  lot,

Filip

1 ACCEPTED 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
    )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

3 REPLIES 3
selimovd
Super User
Super User

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

Anonymous
Not applicable

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
    )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.