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
luigiPulido_
New Member

Filter all records from an order if the order contain one specific product

Hello there,

 

The business problem is that I download a table from shopify where I have the order with all the items that are in that order. The problem is that  orders that has (in this case) the Product 'bbbb' need to be handle different with all  the products in that order.

 

In this case this the comple table

luigiPulido__0-1699983351172.png

And this is the table that I need at the end where only order 1 and 4 has product 'bbbb'

luigiPulido__1-1699984128484.png

 

I tried with data nesting and some filters but to be honest I am not very good with powerquery and M lenguage. My plan B is Macros or Array formulas in Excel but I prefer to  learn something new with power query.

 

 

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

Hello, @luigiPulido_ 

let
    Source = your_table,
    orders = Table.SelectRows(Source, (x) => x[Product] = "bbbb")[Order],
    z = Table.SelectRows(Source, (x) => List.Contains(orders, x[Order]))
in
    z

View solution in original post

3 REPLIES 3
AlienSx
Super User
Super User

Hello, @luigiPulido_ 

let
    Source = your_table,
    orders = Table.SelectRows(Source, (x) => x[Product] = "bbbb")[Order],
    z = Table.SelectRows(Source, (x) => List.Contains(orders, x[Order]))
in
    z

Yes, thats exactly what I was looking for. Thanks, I just need to understand whats going on LOL

@luigiPulido_ well, first Table.SelectRows gives you all rows that contain "bbbb" in Product column. Little touch of [Order] after closing bracket gives us a list of order numbers in that table. You may clearly see this list in PQ editor. Then (step z) we filter original tables' orders column. That is all about Table.SelectRows, columns as lists of items, working with lists functions etc. 

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