Excel Power Query: Replace Errors With Null
In this article
To replace errors with null in Excel Power Query, select the column (or columns) containing errors, go to the Transform tab, click Replace Values, and in the dialog enter the error value in the Value To Find box and leave Replace With blank. Because Power Query treats an empty replace box as null, every error in that column becomes null. Alternatively, use the Replace Errors command on the Transform tab and choose null as the replacement value. Both methods work in Excel for Microsoft 365 and Excel 2021/2019; menu labels can differ slightly by version or region.
What You'll Need
- Excel 2016 or later with Power Query built in (Excel 2010/2013 need the free Power Query add-in from Microsoft).
- A query already loaded into the Power Query Editor (Data > Get Data, or Data > From Table/Range).
- At least one column that contains error values, shown as the word Error in red text.
Step-by-Step
- Open the query in Power Query Editor. In Excel, click any cell in your table, then go to Data > From Table/Range. If the query is already loaded, right-click it in the Queries & Connections pane and choose Edit.
- Find the error column. Scroll the data preview and look for cells that read Error in red. You can also click the column header drop-down and check the filter list; errors appear as a separate entry at the bottom of the list.
- Select the column. Click the column header once. To handle several columns, hold Ctrl and click each header, or hold Shift to select a range.
- Use Replace Values. On the Transform tab, click Replace Values. In the Value To Find box type the word Error (Power Query recognises this as the error value). Leave the Replace With box completely empty. Click OK.
- Confirm the result. The red Error cells should now show null in italic grey text. A new step named Replaced Value appears in the Applied Steps list on the right.
- Alternative: Replace Errors. With the column selected, on the Transform tab click Replace Errors. In the dialog, choose null from the replacement options (or type
nullin the value box) and click OK. This adds a Replaced Errors step. - Check the data type. If the column was typed as Whole Number or Date and now contains nulls, that is fine, but if you later need to filter or aggregate, confirm the type is still correct. Click the type icon in the column header to adjust.
- Close and load. Go to Home > Close & Load (or Close & Load To... to choose a destination). The cleaned data is written back to Excel with nulls instead of errors.
Common Mistakes
- Typing the error text instead of leaving the box blank. If you type null into the Replace With box, Power Query treats it as the text string "null", not a true null. Leave the box empty.
- Replacing errors in the wrong column. Replace Values applies only to selected columns. If you select the whole table, the step may target every column and overwrite values you wanted to keep.
- Forgetting the step order. If a later step (such as a type change or a calculated column) reintroduces errors, the replacement step will not catch them. Move the replacement step after the step that creates the errors by dragging it in Applied Steps.
- Assuming null and blank are the same. A null is an absence of value; an empty text string is a value of zero length. Filters and calculations treat them differently.
Tips
- To replace errors across many columns at once, select all columns, then use Replace Errors; it works on the whole selection.
- Use View > Column Quality to see how many errors exist in each column before you start, so you know which columns need attention.
- If you want a specific fallback value instead of null (for example 0 for numbers), type that value in the Replace With box of Replace Errors.
- Rename the step in Applied Steps (double-click it) to something like "Errors to null" so the query is easier to read later.
- Nulls are ignored by most aggregations such as Sum and Average, which is often exactly what you want when cleaning a numeric column.
Troubleshooting
- The errors remain after the step. Check that the replacement step sits after the step that generates the errors. Drag it down in Applied Steps.
- The Replace Values dialog rejects the word Error. Make sure you are typing it exactly as shown, with a capital E, and that the column actually contains error values rather than text that looks like an error.
- Nulls appear where you expected numbers. This is expected when replacing errors; if you need a numeric fallback, use Replace Errors with 0 instead.
- The query fails to refresh. A downstream step may not accept nulls. Open the step that fails, check its error message, and adjust the type or add a fallback value.
- You cannot find Replace Values. It is on the Transform tab when a column is selected; if the tab is greyed out, click a column header first. Labels vary slightly between versions.
Frequently Asked Questions
Does replacing errors with null delete the row?
No. The row stays; only the error cell becomes null. To remove rows, use Remove Rows > Remove Errors separately.
Can I replace errors in a calculated column?
Yes, provided the column exists in the query and you add the replacement step after the step that creates it.
What is the difference between Replace Values and Replace Errors?
Replace Values swaps a specific value you name; Replace Errors targets any error value in the selected columns regardless of its cause.
Will nulls break my pivot table or chart?
Nulls are simply excluded from aggregations. Pivot tables and charts handle them without error, though blank categories may appear.
Can I undo the replacement?
Yes. Delete the step in Applied Steps, or click the X next to it; the query reverts to the previous state.