web-dev-qa-db-ja.com

IMPORTRANGEを使用して、クエリ内の複数のORステートメントを簡略化する

現在のシートの範囲を使用して、別のシートの値をクエリしようとしています。式を簡略化してすべてのORを削除する方法はありますか?たぶん、FORループを使用したいですか?

=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/sample", "Production!A:P"), 
"select Col1, Col6, Col8, Col16 where 
(Col8 contains '"&Tracking!B2&"')  or (Col8 contains '"&Tracking!B3&"')  or
(Col8 contains '"&Tracking!B4&"')  or (Col8 contains '"&Tracking!B5&"')  or 
(Col8 contains '"&Tracking!B6&"')  or (Col8 contains '"&Tracking!B7&"')  or 
(Col8 contains '"&Tracking!B8&"')  or (Col8 contains '"&Tracking!B9&"')  or 
(Col8 contains '"&Tracking!B10&"') or (Col8 contains '"&Tracking!B11&"') or 
(Col8 contains '"&Tracking!B12&"') or (Col8 contains '"&Tracking!B13&"') or 
(Col8 contains '"&Tracking!B14&"') or (Col8 contains '"&Tracking!B15&"') or 
(Col8 contains '"&Tracking!B16&"') or (Col8 contains '"&Tracking!B17&"') or 
(Col8 contains '"&Tracking!B18&"') or (Col8 contains '"&Tracking!B19&"') or 
(Col8 contains '"&Tracking!B20&"') or (Col8 contains '"&Tracking!B21&"') or 
(Col8 contains '"&Tracking!B22&"') or (Col8 contains '"&Tracking!B23&"') or 
(Col8 contains '"&Tracking!B24&"') or (Col8 contains '"&Tracking!B25&"') or 
(Col8 contains '"&Tracking!B26&"') or (Col8 contains '"&Tracking!B27&"') or 
(Col8 contains '"&Tracking!B28&"') or (Col8 contains '"&Tracking!B29&"') or 
(Col8 contains '"&Tracking!B30&"')", 1)
1

このようにしてみてください:

=FILTER(QUERY(IMPORTRANGE("15YS4mri0m23Z5ai0D3xrGoFw0IYpXNrF-vOpaVYZP_I", "Production!A2:P"),
 "select Col1,Col6,Col8,Col16", 0), 
 REGEXMATCH(IMPORTRANGE("15YS4mri0m23Z5ai0D3xrGoFw0IYpXNrF-vOpaVYZP_I", "Production!H2:H"), 
 ".*"&TEXTJOIN(".*|.*", 1, Tracking!B2:B30)&".*"))

0

0
user0