Search code examples
google-sheetsgoogle-query-languagegoogle-sheets-query

Query ImportRange with date and location


I currently have a file with a bunch of columns with Date in column 1 and location in column 3. I wanted to pull a specific number based on the date and location. Currently, it just keeps pulling the column header based on the query. Attached is the google sheet with Sheet2 pulling the data. Based on the formula, I would like it to return 0.72 in cell B2 Sheet2.

=QUERY(IMPORTRANGE("1Xd0qi9lBuhIwwWAvD7qxkubXPAdo9D0jVC5hkmdd8zA","Sheet1!A:D"),"select Col4 where Col1='"&$A2&"' and Col3='"&B$1&"'")

https://docs.google.com/spreadsheets/d/1Xd0qi9lBuhIwwWAvD7qxkubXPAdo9D0jVC5hkmdd8zA/edit#gid=505310051

Thanks.


Solution

  • Used an alternative method using INDEX/MATCH to get the lookup of the value.

    =ARRAYFORMULA(INDEX(IMPORTRANGE("1Xd0qi9lBuhIwwWAvD7qxkubXPAdo9D0jVC5hkmdd8zA","Sheet1!D:D"),match(1,(IMPORTRANGE("1Xd0qi9lBuhIwwWAvD7qxkubXPAdo9D0jVC5hkmdd8zA","Sheet1!A:A")=A2)*(IMPORTRANGE("1Xd0qi9lBuhIwwWAvD7qxkubXPAdo9D0jVC5hkmdd8zA","Sheet1!C:C")=B1),0)))