Olha
Olha

Reputation: 1

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!

Upvotes: 0

Views: 8042

Answers (1)

Broly
Broly

Reputation: 921

Update: based on the sheet and the data format you have shared, this formula should work:

=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")&"'")

You can use and with where to check for multiple conditions.

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

Upvotes: 2

Related Questions