Extracting Data that meets multiple criteria in one column for one customer ID

MichiganWilliams

New Member
Joined
Jan 15, 2017
Messages
12
I swear this has to be easy but I'm not figuring this out. I've looked at VLOOKUP, Index & Match, Pivot Tables, etc.

I've got a table with 65k rows. In one column, I have a customerID, in another column I have an item purchased. I have many other columns, but I want to be able to find customers that have purchased BOTH item A & item B, doesn't have to be on the same date. When I try filtering my table, I get anyone who purchased either A or B.

I tried a Pivot table and I did Rows Customer ID and column product purchased, I think I threw in another random field in the values column set to Count. It's not exactly what I want though. With 65k rows, that takes a lot of scrolling.
Imagine something like the table below, but with a ton of rows. I'd want it to return only Customer 1 because they've purchased A and they've purchased B. Is there a formula that could extract data like this when it's dependent on a customer ID in one column and multiple criteria in a separate column?

Follow up question, What if I wanted someone who has purchased BOTH A and any other product?
Customer IDProduct PurchasedDate
1A1/1/19
2B1/1/19
3C1/1/19
4A1/1/19
1B2/1/19
5D2/1/19
5E2/1/19
4A2/1/19

<tbody>
</tbody>

Thank you!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
something like this?

Customer IDProduct PurchasedDateCustomer IDProduct Purchased
1​
A
01/01/2019​
1​
A,B
2​
B
01/01/2019​
2​
B
3​
C
01/01/2019​
3​
C
4​
A
01/01/2019​
4​
A,A
1​
B
02/01/2019​
5​
D,E
5​
D
02/01/2019​
5​
E
02/01/2019​
4​
A
02/01/2019​
 
Upvote 0
with PowerQuery aka Get&Transform and M-code below:

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Group = Table.Group(Source, {"Customer ID"}, {{"Count", each _, type table}}),
    List = Table.AddColumn(Group, "Product Purchased", each Table.Column([Count],"Product Purchased")),
    Extract = Table.TransformColumns(List, {"Product Purchased", each Text.Combine(List.Transform(_, Text.From), ","), type text})
in
    Extract[/SIZE]
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top