Power Query course · Lesson 9 of 17

Append queries: stacking tables

Stack monthly or regional tables with Append Queries, handle columns that do not match, tag each row with its source and append every table in a workbook.

Intermediate 14 min read

Append puts the rows of one table under the rows of another. It is the answer whenever the same kind of data arrives in pieces: one sheet per month, one file per branch, one export per sales channel. In a worksheet you would copy and paste, or use VSTACK. In Power Query the stacking is a step, so when a piece changes, the combined table updates on refresh.

This lesson covers appending a handful of named queries. When the pieces are files in a folder, the folder method in Combine files from a folder is even better, but it builds on exactly the same idea.

The sample: two shop exports

ABCD
1DateReceiptItemAmount
22026-04-01A-1101Espresso beans 1kg18.9
32026-04-01A-1102Milk frother34.5
42026-04-02A-1103Paper filters3.2

Before, query 'Shop_Athens': the Athens shop's April sales.

ABCDE
1DateReceiptItemAmountCashier
22026-04-01T-2201Espresso beans 1kg18.9Nikos
32026-04-03T-2202Grinder C40229Eleni

Before, query 'Shop_Thessaloniki': the same columns plus a Cashier column.

Append Queries as New

  1. Create a query for each table (for tables in this workbook: click inside each and choose Data › From Table/Range, then Close & Load To… › Only Create Connection).
  2. In the editor choose Home › Combine › Append Queries › Append Queries as New. (From Excel you can also use Data › Get Data › Combine Queries › Append.)
  3. Choose Two tables, pick Shop_Athens as Primary table and Shop_Thessaloniki as Table to append to the primary table.
  4. Click OK. A new query called Append1 appears. Rename it Sales_All.
ABCDE
1DateReceiptItemAmountCashier
22026-04-01A-1101Espresso beans 1kg18.9null
32026-04-01A-1102Milk frother34.5null
42026-04-02A-1103Paper filters3.2null
52026-04-01T-2201Espresso beans 1kg18.9Nikos
62026-04-03T-2202Grinder C40229Eleni

After: five rows. Columns are matched by name; Cashier exists only in the second table, so it is null for Athens rows.

Power Query M
let
    Source = Table.Combine({Shop_Athens, Shop_Thessaloniki})
in
    Source
Append writes Table.Combine with a list of queries. Add more names to the list to stack more tables.

Append Queries (without as New) adds the append as a new step at the end of the current query instead of creating a new query. That is fine for quick work, but Append as New keeps each source query untouched and reusable, which makes larger workbooks easier to understand.

Three or more tables

Choose Three or more tables in the dialog. Move queries from Available tables to Tables to append with Add >>, and set their order with the arrows. The order decides only the row order of the result.

How columns are matched

  • Columns are matched by name, not by position. Different column order in the sources is not a problem.
  • Names must match exactly, including case and spaces. Amount and amount (with a trailing space) become two separate columns, each half full of nulls.
  • A column that exists in only some tables is filled with null in the others.
  • The result's columns follow the order of the first table, then any extra columns from later tables.
Watch out. The most common append mistake is a header that changed slightly between exports: Amount in January, Amount EUR in February. The append does not fail; it quietly produces two half-empty columns, and a total on Amount is too low. After every append, look at the column quality bar (View › Column quality) for unexpected empty percentages.

Fix mismatched names in the source queries before appending, with a rename step. If the variation is systematic, for example inconsistent case, transform all headers at once with a step such as:

Power Query M
= Table.TransformColumnNames(Source, each Text.Proper(Text.Trim(_)))
Trims and capitalises every column name, so ' amount' and 'AMOUNT' both become 'Amount'.

Tag each row with its source

After stacking, you often need to know where a row came from. Add a custom column in each source query before appending: Add Column › Custom Column, name Shop, formula "Athens". Do the same with "Thessaloniki" in the other query. Now the combined table can be grouped or filtered by shop.

Power Query M
= Table.AddColumn(#"Changed Type", "Shop", each "Athens", type text)
A constant column added before the append.

Appending every table in the current workbook

Suppose each month someone adds a sheet with a new table named Sales_2026_01, Sales_2026_02 and so on. Instead of appending them by hand, read the list of tables in the workbook itself:

  1. Choose Data › Get Data › From Other Sources › Blank Query.
  2. In the formula bar type = Excel.CurrentWorkbook() and press Enter. You get a table with Content and Name columns, one row per table or named range in the workbook.
  3. Filter Name with Text Filters › Begins With Sales_.
  4. Click the expand icon on Content (two arrows in the header), untick Use original column name as prefix, and click OK.
  5. Set the data types and rename the query Sales_All.
Power Query M
let
    Source = Excel.CurrentWorkbook(),
    SalesTables = Table.SelectRows(Source, each Text.StartsWith([Name], "Sales_")),
    Expanded = Table.ExpandTableColumn(SalesTables, "Content", {"Date", "Receipt", "Item", "Amount"}),
    Typed = Table.TransformColumnTypes(Expanded, {{"Date", type date}, {"Amount", type number}})
in
    Typed
The Name column stays in the result, so you also know which table each row came from.
Watch out. When this query is loaded to a table on a sheet, that output table also appears in Excel.CurrentWorkbook(). If its name matched your filter (say you named it Sales_All), the next refresh would append the output to itself and the rows would double each time. Use a filter that cannot match the output, such as Sales_2, or name the output table differently, for example All_Sales.

Append versus Merge

AppendMerge
DirectionAdds rows (stacks vertically)Adds columns (side by side)
MatchingColumn namesValues in key columns
Typical useMonths, branches, channelsLook up product, customer or price details
Excel equivalentVSTACK or copy-pasteXLOOKUP

If you are unsure, ask whether the second table contains more of the same rows (append) or more information about the same rows (merge, see Merge queries: every join kind explained).

Staging queries

The source queries Shop_Athens and Shop_Thessaloniki do not need to be on a sheet. Right-click each in Queries & Connections, choose Load To…, and pick Only Create Connection. Only Sales_All is loaded. In the editor, the italic name of a query in the Queries pane shows that it is not loaded. You can also group helper queries into folders: right-click › Move To Group › New Group…, for example Staging.

Tip. Use Reference rather than Duplicate when you need a second query based on an existing one. Right-click › Reference creates a query whose source is the first query, so a fix in the first flows into both. Duplicate copies all the steps, and you would have to fix them twice.

Check yourself

1. How does Append match columns?

2. One table has Cashier, the other does not. What appears in Cashier for rows from the second table?

3. What M function does Append write?

4. A query appends all tables whose name begins with Sales_ and loads to a table named Sales_All. What happens on refresh?

5. Which right-click option creates a query that follows changes in the original?