Sub topic 1
Where Merge and Append Live in the Power Query Editor
Prerequisites
This chapter assumes that you can open the Power Query Editor from Excel through Data > Get Data or Data > Launch Power Query Editor. You should also know basic column types such as text, number, and date.
Find Merge and Append
In the Power Query Editor, select the Home tab. The Combine group contains:
- Append Queries, which stacks rows from one query under another.
- Merge Queries, which matches rows and adds columns from another query.
The Queries pane on the left lists the queries available for these operations. A query is a saved set of steps that imports and transforms data.
Connection-Only Queries and Load Destinations
A query can be loaded to an Excel worksheet, the Data Model, both, or neither. To change this choice, right-click a query in the Queries & Connections pane and select Load To.
Use Only Create Connection when a query is an intermediate source for another query. This keeps the worksheet uncluttered while allowing later append or merge steps to use it. Final results commonly load to a table or the Data Model.
A connection-only query still refreshes when a dependent query refreshes. Therefore, it is useful for staging data without creating unnecessary worksheet tables.
Append or Merge: Choose by Shape
Choose append when the tables represent the same kind of records, such as monthly sales. Append increases the number of rows.
Choose merge when one table contains details that belong beside rows in another table, such as adding customer regions to orders. Merge increases the number of columns after you expand the match.
| Operation | Main effect | Typical example |
|---|---|---|
| Append | Stacks rows | January sales plus February sales |
| Merge | Adds matched columns | Orders matched to Customers |
Append Two Queries
Select Home > Append Queries. Choose Two tables, select the first and second queries, and confirm. Power Query creates a new query with the rows combined.
The same operation appears in M code:
let
January = #table({"OrderID", "Amount"}, {{1, 100}, {2, 150}}),
February = #table({"OrderID", "Amount"}, {{3, 125}}),
Combined = Table.Combine({January, February})
in
CombinedHow Columns Line Up
Power Query matches appended columns by column name, not by position. If a column exists in only one query, the other query's rows receive null, meaning no value. Different data types can cause errors or unexpected results, so set compatible types before appending. Rename equivalent columns first, such as changing Total to Amount.
Exercise
Two queries have the same columns in different orders. Will Append Queries match values by position?
Show answer
No. Power Query matches columns by name and fills absent columns with null.