Michael Jetzer
Michael Jetzer

Reputation: 59

Use Google Query to return results based on an Array

I have a function that queries an array, material_items and I want it to select all the rows where Column 1 matches another array item_list_typeids. Right now it only uses the first cell in the item_list_typeids in the query when there are currently 5 items in the array. That array is dynamic and there can be much more than just 5 items.

=ARRAYFORMULA(IFNA(
QUERY({material_items}, "select * WHERE Col1 = "&item_list_typeids&"",0),
""))

As you can see in the images below, there are multiple rows pulled for just the first item in the item_list_typeids, so the expected result will be over a dozen rows for just the 5 items in the array.

enter image description here

enter image description here

Upvotes: 1

Views: 1557

Answers (1)

player0
player0

Reputation: 1

go for:

=IFNA(QUERY({material_items}, 
 "where Col1 matches '"&TEXTJOIN("|", 1, item_list_typeids)&"'", 0))

Upvotes: 2

Related Questions