Sub topic 11
Appending Tables with the Same Columns
This chapter assumes you can build a basic query in the Power Query Editor, that you know what Applied Steps are, and that you can set column data types. Append stacks the rows of two or more tables into one longer table. You use it when the same kind of data arrives in separate pieces, such as one table per year, region, or export file.
What append does
Append places the rows of the second table under the rows of the first. Power Query matches columns by name, not by position. If both tables have Date, Region, and Amount, the values line up under those headings even if the columns appear in a different order in each source.
Append differs from merge. Merge adds columns by looking up related rows. Append adds rows. If you are asking "how do I get the 2025 rows under the 2024 rows?", you want append.
Prepare each source first
Append works best when each input query is already clean and typed. Before you append:
- Load each source into its own query, for example
Sales2024andSales2025. - Promote headers and remove junk rows in each query.
- Make column names identical, including spelling, spaces, and capitalization.
- Set the same data type on each shared column.
Cleaning the inputs first keeps each query small and easy to check. It also means a mistake shows up in the query that caused it.
Append in the Editor
You can append from the Excel ribbon or from inside the Power Query Editor.
- Open the Power Query Editor with the first query, for example
Sales2024, selected. - On the Home tab, choose Append Queries. The menu also offers Append Queries as New.
- Choose Two tables and pick the second table from the dropdown. If you have three or more, choose Three or more tables and add each one to the list.
- Select OK.
The two menu items differ in where the result goes:
| Command | What it does | When to use it |
|---|---|---|
| Append Queries | Adds an Appended Query step to the current query, so that query now contains the combined rows | You no longer need the first query on its own |
| Append Queries as New | Creates a new query holding the combined rows and leaves the inputs unchanged | You want to keep the inputs for other uses |
For repeatable work, Append Queries as New is usually the safer choice. The source queries remain available and you can set them to load as connection only (covered in the loading chapter).
The M code behind it
The step is a call to Table.Combine, which takes a list of tables.
let
Source = Table.Combine({Sales2024, Sales2025})
in
SourceTo add a third table, add it to the list: Table.Combine({Sales2024, Sales2025, Sales2026}). The order in the list sets the order of the rows in the result. You can edit this in the formula bar or the Advanced Editor if you need to add or remove a table later.
Column mismatches
Power Query does not stop you when the columns differ. It builds the result from the union of all column names across the inputs. Any table lacking a column gets null in those rows.
Suppose Sales2024 has Date, Region, Amount, and Sales2025 has Date, Region, Amount , with a trailing space. The result has four columns: Date, Region, Amount, and Amount . The 2024 rows have a value in Amount and null in Amount , and the 2025 rows are the reverse. No error appears. Totals on Amount are silently too low.
To fix a mismatch, go back to the input query and rename the column there, rather than patching the result. Then the correction survives refreshes.
Common causes of mismatched names
- Trailing or leading spaces in headers
- Different capitalization, such as
regionandRegion(names are case-sensitive in M) - Different wording across years, such as
AmountandSales Amount - A header row that was not promoted in one source, giving
Column1,Column2
Data types after appending
If a shared column has different types in the inputs, for example Amount as number in one query and text in another, the result column holds mixed values. Power Query may show the column as type "Any" with an ABC123 icon. Sorting, filtering, and summing then behave inconsistently.
Set types in each input query, and then confirm the type on the appended result. Adding a final Changed Type step on the result is a cheap safeguard.
let
Source = Table.Combine({Sales2024, Sales2025}),
Typed = Table.TransformColumnTypes(Source, {{"Date", type date}, {"Amount", type number}})
in
TypedIf a value cannot convert, such as the text n/a in Amount, that cell becomes an error. The chapter on finding and handling errors covers how to deal with those.
Tracking where rows came from
After you combine tables, you often lose the information about which input each row came from. If the inputs do not already contain a year or region column, add one to each input before appending. In the Editor, use Add Column > Custom Column and enter a constant.
let
Source = Excel.CurrentWorkbook(){[Name="SalesRaw2024"]}[Content],
Tagged = Table.AddColumn(Source, "SourceYear", each 2024, Int64.Type)
in
TaggedDo the same in the other input with its own value. After the append, SourceYear identifies each row, and you can group or filter on it.
Limits and alternatives
Append with a fixed list of tables works well when you have a few known inputs. It has two limits:
- If a new table appears next year, you must edit the append step to add it.
- If you have dozens of files, adding each one by hand is slow.
For many files that share a layout, use the folder import method, which combines every file in a folder and picks up new files on refresh. That technique is covered in the chapter on combining all files in a folder.
Also, appending does not remove duplicates. If the same row appears in two inputs, it appears twice in the result. Use Remove Duplicates after the append if overlapping periods are possible, and choose the key columns carefully so you do not drop legitimate repeated rows.
Refreshing an appended query
Because append is a step in the query, refreshing recalculates it. Add rows to SalesRaw2025 and refresh, and the new rows appear in the combined table. Refresh does not add a new input table. Only editing the Table.Combine list does that.
Exercise
You append Orders2024 and Orders2025. The result has columns OrderID, Date, Amount, and Amount_ (the last name has a trailing space). Total Amount is lower than expected. What happened, and where should you fix it?
Show answer
One source has a header with a trailing space, so Power Query treated it as a different column and filled nulls into the rows from the other table. Fix the header in the input query that has the extra space (rename it to Amount), then refresh the append. Fixing it in the input keeps the correction in place on every refresh.
Exercise
You need to combine Sales2024 and Sales2025 into a new query called AllSales while keeping both original queries unchanged. Which command do you use, and which M function does the step call?
Show answer
Use Append Queries as New on the Home tab. The step calls Table.Combine with a list of the two tables, for example Table.Combine({Sales2024, Sales2025}).