Forum Discussion
Help - Find the 2nd match using Xlookup
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.
It seems possible. Here is an example.
Formula:
=XLOOKUP(
F2:F5&H1,
B1:B16&
SORTBY(
SEQUENCE(ROWS(B1:B16),1,2)-MATCH(SORT(B1:B16),SORT(B1:B16),0),
SORTBY(SEQUENCE(ROWS(B1:B16),1,2),B1:B16,1),1
),
C1:C16
)
https://excelmee.com/excel-formulas/lookup/xlookup-nth-occurrence-in-excel-first-last-and-nth/
- LSpurchasingAug 31, 2021Copper Contributorexcelmee
Would this formula need to be revised to find the nth result when using only one lookup value (F2)? I tried the formula you posted and it didn't work in such a case.- excelmeeSep 01, 2021Copper Contributor
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.
- SergeiBaklanAug 31, 2021Diamond Contributor
If you need nth occurrence, the easiest way is based on what PeterBartholomew1 suggested
- MobileTimJan 20, 2023Copper Contributor
Thank you PeterBartholomew1 and SergeiBaklan saved me a ton of time today. Appreciate this community.