Google-sheets – Query reference to several sheets

formulasgoogle sheetsgoogle-sheets-arrayformulagoogle-sheets-queryvlookup

I have this formula:

=ArrayFormula({query(query({A3:D,value(B3:B)}, 
                     "select Col1, sum(Col5), count(Col4), sum(Col3) 
                      where Col1<>'' group by Col1 format sum(Col5) 'h:mm:ss'"),
               "select* offset 1",0), 

 vlookup(query(query(query(A4:D, 
                     "select D, A, sum(C) group by A, D"), 
               "select max(Col3), Col2 group by Col2 label max(Col3)''"), 
         "select Col1")&unique(sort(filter(A4:A, len(A4:A)))), 

 {query(query(A4:D, "select sum(C), A, D  group by A, D"), 
        "select Col1",0)&

 query(query(A4:D, 
       "select sum(C), A, D group by A, D"), 
 "select Col2",0),

 query(query(A4:D, 
       "select sum(C), A, D  group by A, D"), 
 "select  Col3",0)}, 2, 0)})

I got it from a response to another question here in Web Applications, this is an example, I am trying to apply it to my real sheet.

The thing is that this formula is going to be in a different sheet (in one sheet the raw data, in another sheet the analytics using this formula), so how can I call Col1, Col2, etc from another sheet?

Can I mix in the same sentence columns from different sheets?

Example: "Select sheet1!Col1, sum(Col5), count(sheet1!Col4)"

Best Answer

Instead of just using the ranges, you will have to add the sheet name..

e.g:

=ArrayFormula({query(query({'SHEETNAME'!A3:D,value('SHEETNAME'!B3:B)}....ETC