Excel data cleaning

How to Clean Data with Power Query in Excel (Step by Step)

By the DecodingPro teamUpdated 4 min read

Quick answer

Select your data and choose Data, From Table/Range to open the Power Query editor. Use the Transform and Home tabs to trim and clean text, capitalise words, split columns, fill down, remove blanks and remove duplicates, then choose Close and Load. Each action is recorded as a step, so next month you paste the new data in and press Data, Refresh All.

Power Query is built into Excel (Data tab, Get and Transform Data) and does the repetitive part of cleaning for you. It never edits your original data: it reads it, applies your recorded steps and writes a clean copy to a new sheet. If you clean a file with the same problems every week, it saves hours.

Step 1: load the data

  1. Click any cell in your data and press Ctrl+T to turn it into a table (tick "My table has headers").
  2. Choose Data, From Table/Range. The Power Query editor opens.

On the right, the Applied Steps list shows everything you do. You can click any step to see the data as it looked then, rename it or delete it.

Step 2: clean the text

Select the text columns (hold Ctrl and click the headers), then choose Transform, Format:

  • Trim removes spaces at the start and end.
  • Clean removes non-printing characters.
  • Capitalize Each Word fixes ALL CAPS and all lower case. Check names such as McDonald and van der Berg afterwards, as for PROPER in standardising names.

After trimming, compare lengths with a Custom Column such as Text.Length([Name]) against the original if you suspect hidden characters: the non-breaking space and other invisible characters sometimes remain. See removing extra spaces.

Step 3: fix the structure

  • Split a column: Home, Split Column, By Delimiter, for example to separate "Smith, John" or an address.
  • Fill down: Transform, Fill, Down turns blank cells under a group heading into the heading above (a common result of merged cells).
  • Remove blank rows: Home, Remove Rows, Remove Blank Rows.
  • Replace values: Transform, Replace Values, for example "N/A" with nothing.
  • Remove columns: right-click a header, Remove, or keep only the columns you need with Home, Choose Columns.

Step 4: set the right data types

Click the small type icon in each column header and choose Text, Whole Number, Date and so on. Set ZIP codes, IDs and phone numbers to Text so their leading zeros stay (see keeping leading zeros).

For dates in a different format, use Change Type, Using Locale, and choose the locale the dates were written in. That is how you tell Power Query that 03/04/2026 means 3 April rather than 4 March.

Step 5: remove duplicates

Select the column or columns that identify a row, then Home, Remove Rows, Remove Duplicates. Power Query treats John@x.com and john@x.com as different, because its comparison is case-sensitive. Add a lower-case copy of the key column first (Add Column, Format, lowercase), then remove duplicates on that column.

Warning: Remove Duplicates keeps the first row it meets and deletes the others for good in the output. Find them first with the duplicate guide if you are not sure.

Step 6: load and refresh

Choose Home, Close and Load. The clean table appears in a new sheet. Next time, paste the new data over the old table (or point the query at the new file) and choose Data, Refresh All. Every recorded step runs again.

When Power Query is not the right tool

  • It cannot decide that "Jon Smith" and "John Smith" are the same person, or that a date is ambiguous. Those need a human or a checker that flags them.
  • Steps apply to every row the same way. A rule that is right for 99% of rows can quietly damage the rest, so look at the result.
  • It cleans one file at a time and has no record of what changed in each cell. DecodingPro lists every change and flags what it was unsure about.
Try it on your own file

You start with 100 free credits. Every change is logged, and anything unclear is flagged, never guessed.

Fix a spreadsheet

Questions people ask

Does Power Query change my original data?

No. It reads the source and writes the result somewhere else. The original sheet stays as it was.

Is Power Query available in my version of Excel?

It is built into Excel for Microsoft 365, 2016 and later on Windows, under Data, Get and Transform Data. Some features differ in Excel for Mac and in older versions, so check the Data tab.

Can I reuse the steps on another file?

Yes. Change the source of the query (Data, Queries and Connections, right-click the query, Edit, and then Source) to point at the new file, and refresh.

Keep reading

01Excel data cleaningHow to Clean Messy Excel Data: A Step-by-Step GuideThe fixed order that stops one fix from undoing another, with the formulas for every step.10 min read02Text and numbersHow to Keep Leading Zeros in Excel and CSV (ZIP Codes, IDs)Why Excel turns 02134 into 2134, how to get the zeros back, and how to stop it happening when you open a CSV.5 min read03CSV and importsHow to Clean a CSV File Before Importing It Into a CRMSeven fixes that prevent duplicate contacts, rejected rows and scrambled characters, and the 10-row test to run first.4 min read04DatesHow to Fix Dates in Excel and CSV Files (Mixed Formats)Text dates, day-month swaps, two-digit years and the one rule that makes dates safe to share.8 min read05Phone numbersHow to Fix Phone Numbers in Excel: Format and Country CodesLeading zeros, 9.19E+11, country codes and the international format that every system accepts.6 min read06DuplicatesHow to Remove Duplicates in Excel Without Losing DataExact, near and partial duplicates: decide what counts, mark before you delete, keep the best record.6 min read07DuplicatesHow to Find and Highlight Duplicates in ExcelFind repeats safely first: highlight them, count them, keep the first one, and spot the near-duplicates Excel does not see.3 min read08NamesHow to Standardize Names in Excel: Proper Case and ExceptionsWhat PROPER gets wrong, how to protect names that are already right, and how to flip "Smith, John" into "John Smith".4 min read09Email addressesHow to Fix Email Typos in Excel: gmial.com, .con and Missing @The typos that make campaigns bounce, and the formulas and checks that fix them without guessing.4 min read10Email addressesHow to Clean an Email List Before You Send a CampaignA five-step routine that removes the avoidable bounces from a list without deleting anyone you should keep.3 min read11NamesHow to Split Full Names into First and Last Name in ExcelFlash Fill, Text to Columns and formulas for splitting names, and the names that trip each one up.4 min read12Text cleanupHow to Remove Extra Spaces in Excel (TRIM, CLEAN and Non-Breaking Spaces)Why TRIM sometimes does nothing, and the one formula that removes every kind of stray space.3 min read13Text cleanupHow to Remove Special Characters and Line Breaks in ExcelThe characters you cannot see, the smart quotes you can, and the exact formula or shortcut that removes each one.4 min read14NumbersHow to Convert Text to Numbers in Excel (Numbers Stored as Text)Why sums show zero, why numbers sit on the left, and four ways to turn text back into real numbers.3 min read16Comparing dataHow to Compare Two Lists in Excel and Find What Is MissingFind the names, IDs or emails that are in one list and not the other, with formulas that scale.3 min read17CSV and importsFix Garbled Characters and Broken CSV Imports (UTF-8)UTF-8, delimiters, leading zeros, quotes and a checklist that makes a file safe to import.7 min read18Data entryData Entry Accuracy: How to Check, Measure and Improve ItWhat the research says about error rates, why proofreading fails and the checks that actually work.9 min read