Sub topic 6
Appending three or more queries
This chapter assumes you can already append two queries. It also assumes you know how Power Query matches columns by name and what a connection-only query is. Here you will scale that skill up to three or more tables, and you will see how the Append dialog and the M code change as the list grows.
One append step for any number of tables
Many reporting jobs have the same layout repeated across several sources. You might have one sheet per year, one table per region, or one export per month. You could append them two at a time, but Power Query lets you list every table in a single step.
In the Power Query Editor, choose Home > Append Queries. The dialog has two options:
- Two tables gives you a primary table and one second table.
- Three or more tables gives you a list of available queries on the left and a list of tables to append on the right.
With the second option, select a query on the left and choose Add. Repeat for each query. You can also select several queries at once and add them together. The list on the right can be reordered with the up and down arrows beside it.
The dialog has an important quirk. The query you were viewing when you opened the dialog is already in the right-hand list, and in recent versions it is added automatically. If you add it a second time, its rows appear twice in the result. Check the right-hand list for duplicates before you select OK.
What the step generates
The step uses Table.Combine with a list of tables. Whether you append two tables or twelve, the list is the only thing that changes.
let
Source = Table.Combine({Sales_2022, Sales_2023, Sales_2024, Sales_2025})
in
SourceThe curly braces are an M list. Each name inside them is another query, so each one must exist and load without errors. That also means you can edit the step in the formula bar to add or remove a table. Adding Sales_2026 to the list is the same as using the dialog again, and it is quicker.
Append Queries and Append Queries as New
The Append Queries command has a drop-down with two variants.
| Command | What it does | Use it when |
|---|---|---|
| Append Queries | Adds an Appended Query step to the current query. | One query is the natural home for the result. |
| Append Queries as New | Creates a new query that holds the combined result and leaves the sources unchanged. | Each source should stay available on its own. |
With three or more tables, "as new" is usually the better choice. The source queries stay clean, and you can set them to connection only so that only the combined table is loaded to the worksheet. Chapter material on loading options covers that setting. The sources are unchanged, so another query, such as a monthly-only report, can still use them separately.
How the order of the list affects the result
The order of the tables in the list decides two things.
- Row order. Rows from the first table come first, then rows from the second, and so on. Power Query does not sort them. If you need a date order, add a sort step after the append.
- Column order. Columns appear in the order they are first met. The first table sets the opening columns. A column found only in the third table is placed after the columns already collected.
Column matching works the same way as in the two-table case. Columns are matched by name, and the match is case-sensitive, so Amount and amount become two separate columns. A column missing from some tables is filled with null for those rows. With three or more tables, one misspelled header in a single source adds a mostly empty column to the result. You will not see an error. You will see a column of nulls for every row that came from the other tables.
A quick way to catch this is to check the column list of the appended result against your expectation. Look for any column whose values are mostly null.
Tagging rows with their source
After appending, you often can't tell which table a row came from. The fix is to add a column to each source before the append.
let
Tagged2023 = Table.AddColumn(Sales_2023, "Source", each "2023", type text),
Tagged2024 = Table.AddColumn(Sales_2024, "Source", each "2024", type text),
Tagged2025 = Table.AddColumn(Sales_2025, "Source", each "2025", type text),
Combined = Table.Combine({Tagged2023, Tagged2024, Tagged2025})
in
CombinedThis keeps all the work in one query. It adds a step per source, which is acceptable for a handful of tables. If you tag the tables inside the source queries instead, the tag stays with the source wherever it is used.
Data types across many tables
Table.Combine keeps a column's type only when the tables agree. If Amount is a number in two tables and text in the third, the combined column ends up with type any. Excel may then load it as text, or show errors when you apply a numeric step later.
There are two ways to prevent this:
- Set the type in each source query, as its last step, so every table arrives with the same types.
- Pass the expected column types as a second argument to
Table.Combine.
let
Source = Table.Combine(
{Sales_2023, Sales_2024, Sales_2025},
type table [Date = date, Region = text, Product = text, Amount = number]
)
in
SourceWhen you pass a table type, the result uses those columns and types. It also gives the result a fixed column order, no matter which table comes first. Columns that appear in the sources but not in the type are not guaranteed to be kept. Use this form only when you know the complete column list.
Using the type argument does not convert any data. A text value such as "1,250" in a column declared as number is still a text value in the cell. Fix the values in the source query first.
Common failure modes
| Symptom | Likely cause | Fix |
|---|---|---|
| Row count is higher than the sum of the sources | A source was added twice to the list. | Remove the duplicate from the list. |
| Extra column filled mostly with nulls | A header differs in spelling, case, or trailing space in one table. | Rename the column in that source so it matches. |
| Errors in a numeric column after a later step | Mixed types across tables, giving type `any`. | Set types in each source before the append. |
| Result has a different column order than expected | The first table in the list sets the order. | Reorder the list, or use a table type. |
| One source fails and the whole append fails | Any table in the list that returns an error stops the step. | Open the failing source and fix its own steps. |
The last row matters. The append is only as reliable as its weakest source. With many sources, a single sheet that someone renamed will break the refresh for the whole result.
When a list of queries is the wrong tool
Listing queries by name works well when the number of tables is small and fixed. If you receive a new file every month, you would have to edit the list each time. In that case, a folder connection (Get Data > From File > From Folder) combines every file in a folder automatically, and new files are included on refresh. The folder approach assumes the files share a layout, so the same column rules apply.
For a few tables that are all different queries, such as tables from Excel, a database, and a web source, the list in Table.Combine is the right choice.
A short worked check
Suppose Sales_2023 has 1,200 rows, Sales_2024 has 1,350 rows, and Sales_2025 has 400 rows. The appended query should have 2,950 rows. After building the append, compare the row count in the status bar with that sum. A different number points to a duplicate entry in the list, a source that failed to load fully, or a filter step in one source that you forgot about.
Exercise
You append Sales2023, Sales2024, and Sales_2025 with Append Queries as New. The result has an extra column called "Qty" that is null for every row from 2023 and 2024, and a column "Quantity" that is null for 2025 rows. What caused this, and how do you fix it?
Show answer
The 2025 table uses the header "Qty", while the 2023 and 2024 tables use "Quantity". Append matches columns by exact name, so it creates two columns and fills the gaps with null. Rename "Qty" to "Quantity" in the Sales_2025 query (or rename the other two), then refresh. The result will have one Quantity column with no extra nulls.
Exercise
The sources have 1,200, 1,350 and 400 rows, but the appended query has 3,550 rows. Name two likely causes and one way to check each.
Show answer
One cause is that a source query appears twice in the right-hand list of the Append dialog, or that the current query was added again. 3,550 is 600 more than 2,950, so a duplicated or doubled table of that size is the culprit. Open the Table.Combine step in the formula bar and read the list. A second cause is a source that is itself the result of an earlier append that already includes another source. Open each source query and read its steps, looking for a Table.Combine or an Appended Query step.
Exercise
Why might you pass a table type as the second argument to Table.Combine, and what does it not do?
Show answer
It sets the expected columns, their types, and their order for the result, so the output does not depend on which table is first or on mixed types across tables. It does not convert values. A text value in a column declared as number stays text, so the values must be cleaned in the source queries first.