XLOOKUP: searching multiple columns

Hello.

I can't figure out how to search in multiple ROWS and COLUMNS and then return cell from another column.

XLOOKUP($A2;Another table::$E5:$AZ139;Another table::$C;"—";0;1) - gives an error - "Argument 3 of XLOOKUP is invalid."

How to solve it? Is it even possible?

(don't mind punctuations mark, it's different country set)

Thank you for response.


Mac mini, macOS 12.3

Posted on May 28, 2022 1:22 PM

Reply
Question marked as Top-ranking reply

Posted on May 28, 2022 3:21 PM

For as many columns that you want to search I can't offhand think of a way to do it except for one or a small handful of lookups. If it was just a few columns you could concatenate them into one new column and search on that column but you won't want to concatenate columns E through AZ. The first example below uses a column to search each row then you do a lookup on that new column. The second example concatenates columns.



Formula in Table 1 cell D2 =XMATCH(Table 2::B$2;A2:C2;0)>0

fill down to complete the column


Formula in Table 2 cell B2 = XLOOKUP(TRUE,Table 1::D;Table 1::E;"na";0)


Hide column D of Table 1 when it is all set up.


Here is using concatenation:



Formula in Table 1 D2 ="-"&A2&"-"&B2&"-"&C2&"-"

fill down


Formula in Table 2 B2 =XLOOKUP(REGEX("-"&B2&"-"),Table 1::D,Table 1::E,"not found",2)


There may be better choices/combinations of formulas than the ones I used, or even a better way altogether. I don't think there is a way to do it all in one cell, though. I think it will any solution will need a column. But maybe someone else will figure out a way.

5 replies
Question marked as Top-ranking reply

May 28, 2022 3:21 PM in response to Vovchanok

For as many columns that you want to search I can't offhand think of a way to do it except for one or a small handful of lookups. If it was just a few columns you could concatenate them into one new column and search on that column but you won't want to concatenate columns E through AZ. The first example below uses a column to search each row then you do a lookup on that new column. The second example concatenates columns.



Formula in Table 1 cell D2 =XMATCH(Table 2::B$2;A2:C2;0)>0

fill down to complete the column


Formula in Table 2 cell B2 = XLOOKUP(TRUE,Table 1::D;Table 1::E;"na";0)


Hide column D of Table 1 when it is all set up.


Here is using concatenation:



Formula in Table 1 D2 ="-"&A2&"-"&B2&"-"&C2&"-"

fill down


Formula in Table 2 B2 =XLOOKUP(REGEX("-"&B2&"-"),Table 1::D,Table 1::E,"not found",2)


There may be better choices/combinations of formulas than the ones I used, or even a better way altogether. I don't think there is a way to do it all in one cell, though. I think it will any solution will need a column. But maybe someone else will figure out a way.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

XLOOKUP: searching multiple columns

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.