首页 > 解决方案 > How to use several conditions with QUERY + IMPORTRANGE in google sheets?

问题描述

I'm trying to get unique values by using this formula:

=UNIQUE(QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/here goes link","Income!2:8000"),"Select Col15,Col16, Col26 where Col3=" & "'" & B2 & "'"))

And I'm getting the result that I need. The only problem is that I'd like to add an additional condition to it and have no idea how to do it.

I'd like this formula to filter values not only based on Col3 but based on another one, for example, Col3 = B2 and Col2 = A2.

Does anyone have any idea how to do it?

Thank you in advance!

标签: google-sheetsgoogle-sheets-formula

解决方案


更新:根据您共享的工作表和数据格式,此公式应该有效:

=UNIQUE(QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1pXFIWzeHcJPQJtjUqOdgi2FusNGEUoeGlA5rLGNuKLQ/edit#gid=0","data!2:500"),"Select Col15, Col16, Col26 where Col3 = '"&B2&"' and Col2 = date'"&TEXT(DATEVALUE(A2), "yyyy-mm-dd")&"'")

您可以使用andwithwhere来检查多个条件。

=UNIQUE(QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/here goes link","Income!2:8000"),"Select Col15, Col16, Col26 where Col3 = '"&B2&"' and Col2 = '"&A2&"'"))


推荐阅读