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
Quinn
Frequent Visitor

How to write condition in power query to check multiple rows

Like below table, if same PO has 2 lines , i want to check if the value in "Plant" column. If it is same, than add a new column to result "Same Plant", if it's different, then result " Multiple Plant".

For example: PO 510161981 should be "Same Plant"

PO510011416 and 510081262 should be "Multiple Plant"

Quinn_0-1682330766431.png

 

 

 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User
8 REPLIES 8
Ahmedx
Super User
Super User

sorry, need to group by two columns [Po] and [Plant]
I fixed my mistake, you can watch my video again

Quinn
Frequent Visitor

Hi,
I followed your PBIX file and can get the right result!

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

DOLEARY85
Super User
Super User

Hi,

 

you can do this in a few steps:

 

  1. Group By on PO & Plant, adding a count rows aggregation and the data for all other columns in all rows to be expanded later:DOLEARY85_0-1682319385077.png

     

  2. Add a custom column for if the count rows field is greater than 1 same plant else multiple plant:              if [Count] > 1 then "Same Plant" else "Multiple Plant"
  3. Expand the data rows to get any other data back
  4. remove the count rows column:

DOLEARY85_1-1682319527920.png

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

 

I have followed by tyour steps, but there's something wrong, and some times the same PO may have 4 lines, I need result to indicate this PO has "Multiple Plant"

Quinn_0-1682330272468.png

Quinn_1-1682330354655.png

Quinn_3-1682330713257.png

 

 

Ahmedx
Super User
Super User

show how the result should be
and how to understand result "Multiple Plant".

Quinn
Frequent Visitor

PO 512161981 have 2 lines and both Plant is "PlantMY", then result should be "Same Plant",
if same PO have 2 or 3 lines, Plant has "PlantMY" and "Plant00", then the result should be "Multiple Plant"

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.