Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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:
Date | Customer Name | Item Ordered |
2023-11-06 | John | Hat |
2023-11-06 | John | Shoes |
2023-11-06 | Michael | Hat |
2023-11-06 | Michael | Shirt |
2023-11-06 | Chris | Shoes |
2023-11-05 | Michael | Hat |
2023-11-05 | Michael | Shoes |
2023-11-05 | Chris | Shirt |
2023-11-05 | John | Shoes |
2023-11-04 | John | Hat |
2023-11-04 | Chris | Shoes |
2023-11-04 | Chris | Hat |
2023-11-04 | Michael | Shirt |
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
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
8 | |
8 | |
7 |
User | Count |
---|---|
14 | |
13 | |
9 | |
7 | |
6 |