Google Spreadsheets QUERY() to combine multiple sheets, same workbook

Minadorae picture Minadorae · Jan 11, 2017 · Viewed 70.7k times · Source

Goal: I'm using QUERY() in gSheets to combine data from multiple sheets in the same workbook. The data is an extract from GA broken down into small segments to prevent sampling. This means it has all the same fields, I'm just piecing it back together for analysis.

I would like to use QUERY() to do this because the data is hooked up to auto-update using the Google Analytics Sheets addon. The idea is that when it updates in the future it will piece itself together again and the analysis will run without any additional effort (or risk of human error) on our part.

I followed the Google Support syntax, with one accomodation to fit the multiple sheets. This was mentioned on other posts and seems to work for other people--when combined with IMPORTRANGE referencing outside workbooks, though. There has to be a similar way to do it within the same workbook.

What I've tried:

=QUERY({'LandingPages-Oct1'!A16:F,'LandingPages-Oct2'!A16:F},"select *",0)

^ All comma separation causes the sheets to import side by side

=QUERY({'LandingPages-Oct1'!A16:F;'LandingPages-Oct2'!A16:F},"select *",0)

^ Semicolon separating sheets causes the first sheet of data to appear, but not the second

=QUERY({'LandingPages-Oct1'!A16:F;'LandingPages-Oct2'!A16:F};"select *",0)

^ Semicolon separating query parameters returns no results

What am I missing?

Sample data: https://docs.google.com/spreadsheets/d/1STuBdXPCY-mtJdmKZVblR8WlvLaRPa3tl4Kme10sQBQ/edit?usp=sharing

Answer

JPV picture JPV · Jan 11, 2017

Alternatively, you can also use query to remove the empty rows

=QUERY({'LandingPages-Oct1'!A16:F; 'LandingPages-Oct2'!A16:F}, "where Col1 <>''")