top of page

You are learning Power Query in MS Excel

How to combine or merge multiple tables using Power Query?

Combining or merging multiple tables in Power Query allows you to consolidate data from different sources or tables into a single dataset for analysis or reporting purposes. Here’s how you can combine tables using Power Query in Excel:

Types of Table Combining in Power Query

There are several methods to combine tables based on your data requirements:

1. Appending Tables:
- Append tables when you want to stack rows from one table below another. This is useful when tables have the same structure (same columns).

2. Merging Tables:
- Merge tables when you want to combine columns from multiple tables into a single table based on matching values in one or more columns (similar to database joins).

Appending Tables in Power Query

To append tables:

1. Open Power Query Editor:
- Load your first table into Power Query.

2. Append Another Table:
- Go to `Home` > `Append Queries` > `Append Queries as New`.

![Append Queries](https://i.imgur.com/XiMzay2.png)

3. Select Table to Append:
- Choose the table you want to append to the current table.

4. Review and Load:
- Power Query will append the selected table below the existing table.
- Click `Close & Load` to load the appended data into Excel.

Merging Tables in Power Query

To merge tables:

1. Open Power Query Editor:
- Load your first table into Power Query.

2. Merge Queries:
- Go to `Home` > `Merge Queries` > `Merge Queries`.

![Merge Queries](https://i.imgur.com/KES5vCZ.png)

3. Choose Tables and Columns:
- Choose the second table and the columns that you want to use for the merge operation.
- Select matching columns and specify the type of join (e.g., inner join, left outer join, right outer join, full outer join).

![Merge Options](https://i.imgur.com/30c1sSw.png)

4. Configure Merge Options:
- Configure additional options such as matching type (`Left Outer`, `Right Outer`, etc.) and handling duplicates.

5. Review and Load:
- Power Query will merge the selected tables based on the specified columns and join type.
- Click `Close & Load` to load the merged data into Excel.

Example: Appending and Merging Tables

Suppose you have two tables:
- Table1: Sales data with columns `OrderID`, `ProductID`, `Quantity`.
- Table2: Customer data with columns `CustomerID`, `CustomerName`, `City`.

Append Example

1. Open Power Query Editor:
- Load `Table1` into Power Query.

2. Append `Table2`:
- Go to `Home` > `Append Queries` > `Append Queries as New`.
- Select `Table2` to append it below `Table1`.

3. Load Appended Data:
- Click `Close & Load` to load the appended data into Excel.

Merge Example

1. Open Power Query Editor:
- Load `Table1` into Power Query.

2. Merge `Table2`:
- Go to `Home` > `Merge Queries` > `Merge Queries`.
- Choose `Table2` and specify `CustomerID` as the matching column.
- Configure the join type (e.g., `Left Outer` to include all rows from `Table1`).

3. Load Merged Data:
- Click `Close & Load` to load the merged data into Excel.

Advanced Tips

- Handling Complex Merges: Use `Advanced Editor` to customize M language code for complex merge operations, such as conditional joins or multiple join criteria.

- Data Quality: Ensure data consistency and alignment before merging or appending tables to avoid unexpected results.

By following these steps, you can effectively combine or merge multiple tables using Power Query in Excel, allowing you to integrate data from different sources and perform comprehensive data analysis and reporting tasks.

bottom of page