Power Query Problems

Fix Power Query Duplicating Rows After Merging Tables

Elise WilliamsElise Williams Oct 28, 2026 871 views

Question details

The user is experiencing duplicated rows after merging two tables and expanding the results in Power Query.

How to Fix Power Query Duplicating Rows After Merging Tables
Product
Microsoft Excel
Device & OS
not provided
Scenario
Merging multiple data sources using a common identifier (e.g., GSPAS number) and expanding the merged table to view the combined data.
Observed behavior
Rows are unexpectedly duplicated after the expansion step because the join field (merge key) appears multiple times in one or both of the source tables.
Before you start

Verify your source tables to identify if there are multiple records sharing the same ID or key. Understanding which table contains the duplicates will determine how you should aggregate or filter the data before merging.

Solution 1Recommended

Group Source Tables to Make Merge Keys Unique

Use the Group By feature to aggregate your data and ensure every merge key is unique before performing the join.

When you perform a merge (join) in Power Query, matching a key that has multiple instances in both tables creates a Cartesian product, multiplying the rows. To prevent this, you must consolidate the duplicate records in your source tables.

1
Select the Source Query

Open the Power Query Editor and select the query representing the source table that contains duplicate keys.

2
Group By the ID Column

Select the column you are using as the merge key (e.g., ID or GSPAS number). Go to the Transform tab on the ribbon and click 'Group By'.

3
Set Aggregation Rules

In the Group By dialog box, specify how to handle the other columns. Choose an operation like 'Sum' for numerical values to consolidate them into a single row per ID. Alternatively, you can use M code: Table.Group(Source, {"ID"}, {{"Value", each List.Sum([Value]), type nullable number}}).

4
Perform the Merge

Once the merge key is unique, go to the Home tab, click 'Merge Queries', choose a Left Outer Join, and expand the resulting column.

Group Source Tables to Make Merge Keys Unique
Unique Keys Ensured: Grouping ensures that there is exactly one row per ID, completely eliminating the duplicated rows issue upon expansion.
Free Microsoft Office alternative

Effortlessly Manage and Merge Data with WPS Office

If complex Power Query merges and M-code troubleshooting are slowing you down, try WPS Office. It provides a lightweight, highly compatible spreadsheet environment with intuitive data consolidation and lookup tools, making table management effortless.

  1. 1. Download the Application: Visit the official WPS website to download and install the free WPS Office suite.
  2. 2. Open Your Data File: Launch WPS Spreadsheet and open your existing Excel workbooks without losing any formatting or data.
  3. 3. Merge Data Intuitively: Use built-in functions like XLOOKUP or the Consolidate tool to merge tables without the complexities of Power Query.
Fully compatible with Microsoft Excel (.xlsx, .xls, .csv) formats.Intuitive VLOOKUP and Data Consolidation tools for simple table merging.Lightweight installation with smooth performance on older devices.Free to use with comprehensive data analysis functionalities.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Power Query multiply my rows after a merge?

This occurs because Power Query performs a Cartesian product when duplicate keys exist in both tables. If Table A has 2 rows with 'ID 1' and Table B has 3 rows with 'ID 1', expanding the merge will generate 6 rows (2x3) for that single ID.

How can I easily find duplicates in my Power Query table?

To locate duplicates, select the column you want to verify, go to the Home tab, click on 'Keep Rows', and select 'Keep Duplicates'. This will filter the table to show only the repeating values.

Is there an alternative to merging if I only want the first matching value?

Yes. Instead of merging in Power Query, you can load your tables into the spreadsheet and use standard lookup functions like VLOOKUP or XLOOKUP. These functions inherently only return the first match they find, preventing row multiplication.