Forum Discussion
RandomPanda1933
Dec 12, 2024Copper Contributor
Xlookup with nested IF
Thank you in advance for your help. What I am trying to do is return a value (using Xlookup) but only if another value matches. Maybe I need to use Index/Match, but here's my example: Col A Col B...
PeterBartholomew1
Dec 15, 2024Silver Contributor
A more general approach, available in Excel 365, is to define a Lambda function to do whatever you require. For example
ARRLOOKUPλ
= LAMBDA(lookup_values, lookup_array, return_array,
XLOOKUP(
TRUE,
BYROW(lookup_array = lookup_values, AND),
return_array
)
);
will allow you to lookup a row of values in the corresponding range of the data array using a formula
= ARRLOOKUPλ(selectedValues, HSTACK(answer, name), value)
where, in this instance, selectedValues is a 2 cell range containing "Yes" and "Smith".
From there, the task just tends to grow. Maybe you might want unspecified cells in the lookup values to match any value from the lookup array; and so it goes on!😅