Search code examples
regexgoogle-sheetsfiltergoogle-sheets-formulatextjoin

Use a single column to index/match in two columns


I want to use a single column to do a lookup in two columns. Example below.

| a |   | c | a | foo |   | c | a | foo |
| b |   | e | c | bar |   | b | a | baz |
| c |   | b | a | baz |
| d |

The first table is the data I'm using to match on.

The second table is the data table that I'm indexing into.

The third table is the result I want.


Solution

  • try:

    =FILTER(C:E, 
     REGEXMATCH(C:C&"", "^"&TEXTJOIN("$|^", 1, A:A)&"$"), 
     REGEXMATCH(D:D&"", "^"&TEXTJOIN("$|^", 1, A:A)&"$"))
    

    0

    note, it's case sensitive