0
votes

I am trying to query only result that match a pre-defined list in Google Sheets.

This formula is working...but what if my WHERE list contains thousands of entries? Is there a better way?

=QUERY(DATA!A2:B,"SELECT B WHERE A = 'Data 1' OR A = 'Data 6' OR A = 'Data 8'")

Sheet #1 - Contains the data I would like to query.

|   A    |      B      |
| Data 1 | Something 1 |
| Data 2 | Something 2 |
| Data 3 | Something 3 |
| Data 4 | Something 4 |
| Data 5 | Something 5 |

Sheet #2 - Contains a pre-defined list (Column A) & a query formula (Colum B).

|   A   |     B      |
| Data1 | Something1 |
| Data6 | Something6 |
| Data8 | Something8 |

Here is the formula I have tried:

=QUERY(DATA!A2:B,"SELECT B WHERE A = '"&A2:A&"'")

Here is my Google Sheet: Click Here

1

1 Answers

1
votes

Try this in cell Formula!C2:

=arrayformula( iferror( vlookup(A2:A, DATA!A2:B, columns(DATA!A2:B), false) ) )