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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors