Search code examples
google-sheetsuniquegoogle-sheets-formulagoogle-sheets-querygoogle-query-language

Google Sheets' QUERY multiple sheets and return unique values


I need to query two sheets and return all columns and unique values which match specific criteria.

I've used this but it doesn't work:

=UNIQUE(QUERY(Sheet1!A:D,Sheet2!A:D, "select * where B=0"))

My shared sheet:

https://docs.google.com/spreadsheets/d/1ysuvyBHU21uXv_DxzBJwC7tMnGPyaqFqab7m1d-vwyo/edit?usp=sharing


Solution

  • =UNIQUE(QUERY({Sheet1!A:D; Sheet2!A:D}, "where Col2=0"))
    

    0


    =UNIQUE(QUERY({
     Sheet1!A:D, {"Name"; TRANSPOSE(SPLIT(REPT("♦Comp1", ROWS(Sheet1!A:A)-1), "♦"))}; 
     Sheet2!A:D,          TRANSPOSE(SPLIT(REPT("♦Comp2", ROWS(Sheet2!A:A)),   "♦"))}, 
     "where Col2=0"))
    

    0