In gsheets how do I pull data from multiple sheets within the workbook in a query?

Viewed 40

This is what I have so far. It worked fine before adding in the BinCounts ref.

=query(
{'Aggregated Data'!A2:G , BinCounts!A2:G}, "SELECT A, B, C, E, DAY(B), YEAR(B)" & if(COUNTBLANK(Sheet14!A1:A4)=4,""," WHERE " & TEXTJOIN(" AND ", True, Sheet14!A1:A4) & "WHERE Col1 <>"),1)
1 Answers

You should use ; instead of , in between multiple sheets.

Query should look like this:

=query( {'Aggregated Data'!A2:G; BinCounts!A2:G}, "SELECT A, B, C, E, DAY(B), YEAR(B)" & if(COUNTBLANK(Sheet14!A1:A4)=4,""," WHERE " & TEXTJOIN(" AND ", True, Sheet14!A1:A4) & "WHERE Col1 <>"),1)

Sample query that queries multiple sheets.

sample query

Reference:

Related