Search code examples
if-statementgoogle-sheetsmatchgoogle-sheets-formulaflatten

Search for a value in multiple columns and return value from Column A


Sheet Example:

A B C D E F
Jonas 1 6 11 16 21
Joaquin 2 7 12 17 22
William 3 8 13 18 23
Mark 4 9 14 19 24
Stuart 5 10 15 20 25

Search value example:

19

Expected Return:

Mark

Formula indicated:
https://stackoverflow.com/a/55119579/11462274

=QUERY(Clients!A1:F, "select A where B="&B1&"
                              or C="&B1&"
                              or D="&B1&"
                              or E="&B1&"
                              or F="&B1&"", 1)

But the result is:

Jonas
Stuart

Why is Jonas returning when there is no value 19 in row 1?

An additional info:

If I have Columns from B to CC with values, is this still the indicated method? I ask because of the immense amount of lines I would have to write one by one for each of these columns.


Solution

  • try:

    =INDEX(TEXTJOIN(", ", 1, IF(B1:F5=I1, A1:A5, )))
    

    enter image description here