Google Sheets query return all rows if they match any value in a column on another sheet

◇◆丶佛笑我妖孽 提交于 2021-02-08 11:19:33

问题


I have a google sheet with 3 tabs. I want to have tab3 pull all rows from tab1 (southware) into tab3 if there is a match to any value on tab2 (Top)column B

=query(southware!B3:AA,"SELECT * WHERE I = '"&Top!B3&"' and D='112'", 0)

I can get it to pull all the rows for only 1 cell on tab2- how do I make it evaluate all the values in column B on tab2


回答1:


See if this helps

=query(southware!B3:AA,"SELECT * WHERE I matches '"&TEXTJOIN("|", 1, Top!B3:B)&"' and D='112'", 0)



回答2:


QUERY is not able to work with arrays that's why you will need to use FILTER:

=FILTER(southware!B3:AA, I3:I = Top!B3:B, 
                         D3:D = "112")

but this will may have few limitations, so in such case use this one:

=QUERY(ARRAYFORMULA(VLOOKUP(Top!B3:B, 
 {southware!I3:I, southware!B3:AA},
 {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27}, 0)),
 "where Col3='112'", 0)


来源:https://stackoverflow.com/questions/54755115/google-sheets-query-return-all-rows-if-they-match-any-value-in-a-column-on-anoth

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!