Fix Power Query Duplicating Rows After Merging Tables
Question details
The user is experiencing duplicated rows after merging two tables and expanding the results in Power Query.

- 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.
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.
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.
Open the Power Query Editor and select the query representing the source table that contains duplicate keys.
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'.
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}}).
Once the merge key is unique, go to the Home tab, click 'Merge Queries', choose a Left Outer Join, and expand the resulting column.

Remove Duplicate Rows Before Merging
If you do not need to aggregate the numerical data and simply want to keep one unique instance of each key, you can remove duplicates directly.
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. Download the Application: Visit the official WPS website to download and install the free WPS Office suite.
- 2. Open Your Data File: Launch WPS Spreadsheet and open your existing Excel workbooks without losing any formatting or data.
- 3. Merge Data Intuitively: Use built-in functions like XLOOKUP or the Consolidate tool to merge tables without the complexities of Power Query.

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.




