Curly brackets let you stack two ranges into one block, which QUERY can then treat as a single table. Write {range1;range2} to put the second range under the first, and then use column names Col1, Col2 and so on inside the query instead of letters.
How do I stack two tabs?
Assume tabs named FY 2024-25 and FY 2025-26, each with Date, Merchant, Amount and Category in columns A to D, headers in row 1. Because the tab names contain spaces, put them in single quotes:
- ={'FY 2024-25'!A1:D500; 'FY 2025-26'!A2:D500}
The semicolon stacks the ranges vertically. Notice the second range starts at row 2, so the header is not repeated in the middle of your data. If your locale uses different separators, such as a backslash for columns, Sheets will show the right one when you type the formula.
How do I query the stacked block?
Put the whole stacked expression where the data range would go. Inside a stacked array the columns are named Col1 to Col4, not A to D:
- =QUERY({'FY 2024-25'!A1:D500; 'FY 2025-26'!A2:D500}, "select Col4, sum(Col3) where Col3 is not null group by Col4 order by sum(Col3) desc label Col4 'Category', sum(Col3) 'Two-year total'", 1)
Say Groceries is 40,000 on the first tab and 46,000 on the second. The combined result shows 86,000 for Groceries, which is 40,000 plus 46,000.
| Piece | What it does |
|---|---|
| { } | Builds an array from the pieces inside |
| ; (semicolon) | Stacks the next range below |
| , (comma) | Places the next range to the right, with the same row count |
| Col1, Col2 | Column names inside an array |
| Third argument 1 | Treats the first row of the block as the header |
What must match between the tabs?
- The same number of columns, in the same order. If one tab has an extra Notes column, limit both ranges to the shared columns.
- Matching data types. If Amount is a number on one tab and text on the other, QUERY may ignore the odd cells in that column, so convert them first.
- The same category spellings, or the combined table will show Groceries and groceries as separate rows unless you wrap with lower() or upper().
If the column counts differ, Sheets shows an error about an array literal missing values for one or more rows. Fix the ranges to the same width and the error goes.
How do I remove the repeated header row?
Start the second range at the row after its header, as in A2:D500. If you forgot, the second tab's header shows up as a data row. You can filter it out with a where clause, such as where Col1 <> 'Date', or by simply moving the start row.
Can I include another file?
Yes. Wrap the other file's range in IMPORTRANGE, giving it the other spreadsheet's link and the tab and range, and put it inside the braces in place of a local range. The first use asks you to allow access between the two files. Keep file names tidy so you remember which year is which.
A checklist before you trust the result
- Count the rows in the stacked block against the two tabs.
- Add one category by hand on each tab and compare with the query.
- Check the headers show once.
- Extend ranges beyond the last data row, or use open-ended ranges like A2:D.
What about three or more years?
Keep stacking, separating each range with a semicolon: {range1; range2; range3}. Every range must have the same number of columns. If you plan to add a tab every April, consider keeping all years on one tab with a Year column instead, so the formula never needs editing.
If you keep a new tab for each year just to hold statements, importing them into one tracker such as SpendixAI avoids stacking tabs, since each transaction keeps its account and date in a single workspace.
Useful ideas start with a clearer picture of your own spending.
Explore your reports


