Search code examples
google-sheetsfiltergoogle-sheets-formulagoogle-sheets-querytextjoin

Query one column for matches, then return an array of data in the column directly to the left


I tagged sql in here because apparently the query function uses the same syntax.

enter image description here

My goal is for:

  1. Each data value in column E to individually query column B for matches
  2. If there is a match, add it to a array
  3. Display the array in column G (next to the corresponding cell)

EX:

If I query column B for "Heavy lifting/straining", the cell in column G will show "Musculoskeletal, Herniation"


Solution

  • try this:

    =JOIN(", "; FILTER(A:A; B:B=E7))
    

    for partial matches:

    =JOIN(", ", FILTER(A:A, REGEXMATCH(B:B, E8)))
    

    enter image description here