Forum Discussion
Nick_Orem
Jan 19, 2023Copper Contributor
Last product purchased
I have a file of customers and products they have purchased with the date for each purchase. Some customers have many purchases, some have only one. I want to create a new file that shows only the last product purchased for each customer. Here's a sample of the data:
date | user_name | user_id | product_id | product_name |
1/17/2022 22:58 | Kate | 1 | 3845 | Individual (Under 40) 2022 |
2/17/2021 19:41 | Kate | 1 | 1249 | Individual 2020 |
1/10/2022 18:02 | Douglas | 2 | 3843 | Couple 1 - 2022 |
3/4/2021 0:00 | Douglas | 2 | 1228 | Couple 1 - 2021 |
2/16/2021 22:29 | Douglas | 2 | 1242 | Couple 1 - 2020 |
2/16/2021 22:29 | Susan | 3 | 1246 | Couple 2 |
1/10/2022 7:52 | Mariann | 4 | 3846 | Individual 2022 |
1/10/2022 7:49 | Mariann | 4 | 1237 | Individual 2021 |
2/16/2021 22:29 | Mariann | 4 | 1249 | Individual 2020 |
2/16/2021 22:29 | Henrik | 5 | 1233 | Honorary |
1/13/2022 14:38 | Chace | 6 | 3843 | Couple 1 - 2022 |
2/16/2021 22:29 | Chace | 6 | 1242 | Couple 1 - 2020 |
2/12/2021 0:00 | Chace | 6 | 1228 | Couple 1 - 2021 |
2/16/2021 22:29 | Josie | 7 | 1246 | Couple 2 |
1/8/2022 15:25 | Karl | 8 | 3846 | Individual 2022 |
11/19/2021 21:22 | Karl | 8 | 1237 | Individual 2021 |
2/16/2021 22:29 | Karl | 8 | 1249 | Individual 2020 |
1/19/2022 16:04 | Carter | 9 | 3846 | Individual 2022 |
2/16/2021 22:29 | Carter | 9 | 1249 | Individual 2020 |
2/11/2021 0:00 | Carter | 9 | 1237 | Individual 2021 |
- mathetesSilver Contributor
See attached. You'll need a very recent version of Excel for these functions to work. There are two formulas.
=UNIQUE(B2:B21) produces a list of unique customer names
then
=FILTER($D$2:$D$21,
($B$2:$B$21=H3)*($A$2:$A$21=MAX(FILTER($A$2:$A$21,B$2:$B$21=H3))))
gets the most recent (MAX) order date & time and then matches that against products ordered by that customer.