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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors