Sub topic 3
Append or merge: choosing the right operation
This chapter assumes you can load tables into the Power Query Editor, you know the basic column data types (text, number, date), and you have a general idea of what a lookup or join does. Its job is to help you pick the right operation before you click anything.
Two operations, two directions
Power Query combines tables in two ways. They grow the result in different directions.
- Append stacks rows. The result has the same kind of columns as the inputs, and more rows.
- Merge adds columns. It matches rows from one table to rows in another on a key column, like a join or a lookup. The result has the rows of the first table (subject to the join kind) and extra columns from the second.
Both commands are on the Home tab of the Power Query Editor, in the Combine group: Append Queries and Merge Queries.
The deciding question
Ask what the two tables have in common.
| If the tables share... | They describe... | Use |
|---|---|---|
| The same columns | The same kind of record, split across files, months, or regions | Append |
| A key column but different other columns | Different facts about the same entities | Merge |
A quick test: would the combined table have one row per original row from both tables? Then append. Would each row from the first table gain new fields taken from a matching row in the second? Then merge.
Worked examples
Monthly or yearly files. You have Sales_2023 and Sales_2024, each with Date, Product, and Amount. These are the same kind of record, so you append. The stacked result is one table with all rows from both years.
let
Source = Table.Combine({Sales_2023, Sales_2024})
in
SourceOrders and customers. Orders has OrderID, CustomerID, and Amount. Customers has CustomerID, Name, and Region. Each order needs the customer's name and region, so you merge on CustomerID. A left outer merge keeps every order and adds the matching customer details.
let
Source = Table.NestedJoin(Orders, {"CustomerID"}, Customers, {"CustomerID"}, "Customers", JoinKind.LeftOuter),
Expanded = Table.ExpandTableColumn(Source, "Customers", {"Name", "Region"}, {"Name", "Region"})
in
ExpandedThe merge step creates a column holding a nested table for each row. Expanding that column turns it into ordinary columns. Later chapters cover expanding and join kinds in detail.
Common mistakes
- Merging when you should append. If both tables have the same columns, a merge cannot stack them. You would get a nested column of tables, not extra rows.
- Appending when you should merge. Appending tables with different columns still works, but columns found in only one table are filled with
nullin the other rows. The result looks wide and sparse, and nothing links a customer to their orders. - Expecting merge to add rows. Merge normally keeps or filters the rows of the first table. It only adds rows in special cases, such as a full outer join, or when one row matches several rows in the other table.
Doing both
Real tasks often need both. You might append the 2023 and 2024 sales tables, then merge the result with Customers. Append first so the merge runs once, against one complete table. A later chapter builds this pipeline step by step.
Exercise
You have a Budget table with Department, Month, and Planned, and an Actuals table with Department, Month, and Spent. You want one table that shows Planned and Spent side by side for each Department and Month. Do you append or merge, and which columns do you match on?
Show answer
Merge, because you are adding columns (Spent next to Planned), not stacking rows. Match on both Department and Month, since neither column alone identifies a row.
Exercise
You receive one Excel file per region, each with the same columns: Date, Product, Units. You want one table of all regions. Append or merge?
Show answer
Append. The tables have the same layout and describe the same kind of record, so stacking the rows gives one table.