New Tool Radar

AI for Data & Spreadsheets

How to Remove Duplicates in Power Query After Fixing Case and Spaces

Standardise case and trim spaces in Power Query first, then remove duplicates, so near-identical values are caught.

Schematic with three steps: Fix case and spaces first; Remove duplicates on the key columns; Check the row count before and after.

Removing duplicates is case-sensitive in Power Query: Ada Superstore and ADA SUPERSTORE count as different values, and a trailing space makes two values different too. Fix case and spaces first, then remove duplicates, or the near-duplicates survive.

What you need

  • Excel with the data loaded in the Power Query Editor
  • A note of which columns define a unique record
  • A copy of the source file

Step 1: Fix case and spaces first

Select the key columns and apply Transform, Format, Trim, then lowercase or Capitalize Each Word so the case is consistent. Do this before any duplicate step, or the duplicates will not be recognised.

Step 2: Remove duplicates on the key columns

Select the columns that define a unique record, then choose Home, Remove Rows, Remove Duplicates. Power Query keeps the first occurrence of each key value.

Step 3: Check the row count before and after

Note the row count at the bottom of the editor before and after the step. The difference is the number removed; compare it with the number of repeats you expected, and undo the step if it removed rows it should have kept.

Worked example: synthetic 50-row store list

The table below is a synthetic example. It shows the expected result of removing duplicates in Power Query; no file was imported.

Check Count Result
Rows before 50 Source
Rows after case fix 50 No rows removed
Rows after Remove Duplicates 47 3 removed
Unique stores remaining 47 Pass

Expected result (UNTESTED). 50 rows go in, 3 duplicates are removed after the case fix, and 47 unique stores remain. Without the case fix, the three case-different repeats would have survived. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Power Query duplicate removal is case-sensitive, unlike Excel Remove Duplicates.
  • Remove duplicates only after deciding which columns define a unique record.
  • The Applied Steps list is the cleaning log; click a step to see the data at that point.

Sources

See all