Feb 12 2021 04:51 AM
Is there a way using XLookup to return the 2nd (or 3rd, or 4th, or whatever) match in the lookup value? I'm also trying to use as few helper columns as I can. Otherwise I'd just use the VLookup function.
My task is to look through purchase orders and create a pivot table that broke down how much of each material was used. When I created the table I didn't know that there could be multiple instances of the same material in each purchase order.
Here's an example of what I'm looking at.
Order 1 Material 1 6 Inches
Order 1 Material 1 6 Inches
Order 1 Material 2 32 Inches
Order 1 Material 3 41 Inches
Order 2 Material 1 7 Inches
Order 2 Material 2 33 Inches
Order 2 Material 2 33 Inches
Order 2 Material 3 41 Inches
Order 2 Material 4 16 Inches
Order 3 Material 1 6 Inches
Order 3 Material 1 6 Inches
Order 3 Material 1 8 Inches
Order 3 Material 2 19 Inches
Order 3 Material 3 40 Inches
Order 3 Material 3 41 Inches
Order 3 Material 4 18 Inches
Feb 12 2021 07:59 AM
@JMunoz4 Are you sure a regular pivot table won't work? See attached.
If this does not make sense, how exactly would you want to summarise the data?
Feb 12 2021 09:18 AM
If you wish to list multiple matches FILTER would be a more appropriate function
= FILTER(Orders[[Material]:[Size]], Orders[Order]=Selected)
If you wish to aggregate similar values then that could be a Pivot Table or SUMIFS/COUNTIFS combined with UNIQUE to identify the possibilities.
Feb 12 2021 09:43 AM
Thank you. I am still curious if XLOOKUP can return the nth match in an array. But now that you mention it, redoing the pivot table would be the best way to display what I'm looking for. I don't have much experience with pivot tables so I sorta reverse engineered one from a similar worksheet.
Jun 24 2021 08:44 PM
Aug 31 2021 01:02 PM
Aug 31 2021 01:29 PM
If you need nth occurrence, the easiest way is based on what @Peter Bartholomew suggested
Aug 31 2021 09:23 PM
@LSpurchasing You just need to change F2:F5&H1 to F2&H1.
If you have a single search key better follow the Index + Filter combo.
Jan 20 2023 08:12 AM
Thank you @Peter Bartholomew and @Sergei Baklan saved me a ton of time today. Appreciate this community.
Jan 21 2023 04:44 AM
@MobileTim , glad to know this forum helped