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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jdutle
New Member

Power Query - Logic Categorize and Group by

Hello. I am new to using Power Query and have gotten stuck on something and am looking for some help.

 

In a data set I would like to categorize the values in one of the fields using some kind of If/Then/And/Or logic. I can figure out the logic if I was using an Excel formula, but I am struggling to transfer to Power Query. After categorization, I want group the data by the new Category field and an Order Number. Below is was I am trying to accomplish. Its a made up situation, so the scenario might seem a little goofy.

 

Thank you in advance for any help you can provide.

 

1. Categorize - If under the same Order Number create the following values in a Item Category Field:

  • "Coke" and "Ice" appear, I want to categorize to "Coke & Ice"
  • "Ice" only appears, I want to categorize to "Ice Only"
  • "Coke" only appears, I want to categorize to "Coke & Ice"
  • "Veggie Burger" or "Beef Burger", I want to categorize to "Burger"

2. Group - If the same Order Number and Category combine the records
Item field is no longer needed

  • Cost should be summed if same Order Number and Category
  • Expiration Date: earliest date should be used for the grouping
  • Location and Owner: should have the same data for the grouping, so only one value needs to be retained

Example.png

1 ACCEPTED SOLUTION
mussaenda
Super User
Super User

2 REPLIES 2
mussaenda
Super User
Super User

mussaenda_0-1695282731910.png

 

That works perfectly. Thank you!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors