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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
newbie2powerbie
New Member

Filtering for having specific values in multiple rows

Hi all,

 

Was trying to figure out how to word this properly, I think the title gets close but an example is better. What I am trying to do is get a list of customers that have ordered 2 specific items on the same day using Power Query to filter out the rows that don't fit the conditions. Here's an example table:

DateCustomer NameItem Ordered
2023-11-06JohnHat
2023-11-06JohnShoes
2023-11-06MichaelHat
2023-11-06MichaelShirt
2023-11-06ChrisShoes
2023-11-05MichaelHat
2023-11-05MichaelShoes
2023-11-05ChrisShirt
2023-11-05JohnShoes
2023-11-04JohnHat
2023-11-04ChrisShoes
2023-11-04ChrisHat
2023-11-04MichaelShirt

 

What am I hoping to be able to do is end up with a list of customers that ordered a hat and shoes on the same day (not hat and shirt, or not hat one day and shoes another day), so John on 2023-11-06, Michael on 2023-11-05, and Chris on 2023-11-04. Is that something that can be done with Power Query?

 

Thanks

2 REPLIES 2
slorin
Super User
Super User

Hi,

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtY1NNQ1MFPSUfLKz8gDUh6JJUqxOtjlgjPyU4sxZX0zkzMSU3NwaUZIB2dkFmFR4JxRlFmM3XhT/MabohmPVT/CeAzbTfH6zQRPqJjgdzeyNFa9GIESCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"Customer Name" = _t, #"Item Ordered" = _t]),
#"Select Item" = Table.SelectRows(Source, each [Item Ordered] = "Hat" or [Item Ordered] = "Shoes"),
Distinct = Table.Distinct(#"Select Item"),
Group = Table.Group(Distinct, {"Date", "Customer Name"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
#"Count = 2" = Table.SelectRows(Group, each [Count] = 2)
in
#"Count = 2"

Stéphane 

ThxAlot
Super User
Super User

DAX is a way much better solution to such a question in terms of conciseness, flexibility or interactivity.

ThxAlot_0-1699299119802.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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