Sub topic 9
Finding, removing, and replacing errors
This chapter covers cell-level errors in Power Query: where they come from, how to find them, and how to remove or replace them. It assumes you can open the Power Query Editor, read the Applied Steps pane, and set data types (see the earlier chapters on data types and duplicates). It also assumes you can read basic M code.
What an error value is
An error value is a cell that Power Query could not compute. The cell shows Error in the grid instead of data. This differs from null, which means "no value" and is a valid result. An error means a step failed for that cell.
Errors are stored per cell, not per row. A row can have one good column and one error column. Clicking the word Error in a cell (not the cell itself) opens a detail pane. The pane shows a message such as DataFormat.Error: We couldn't convert to Number. and the offending value, such as abc.
Common causes:
- Changing a column to a type that some values cannot satisfy, such as text
abcto number. - Parsing dates with the wrong locale, such as
31/12/2026read asen-US. - Arithmetic on text, such as
[Amount] * 2whenAmountis text. - Dividing by zero in a custom column.
- Source problems, such as an Excel cell that contains
#N/Aor#DIV/0!.
Errors appear late
Power Query evaluates lazily. The editor previews only a sample of rows, so an error may not show in the preview but may appear after you load the full table. A value that converts fine in the first 1,000 rows can fail in row 50,000.
Two habits help:
- Check Column quality after each type change, and set Column profiling to Based on entire data set (status bar at the bottom of the editor).
- Check the table again after loading, in Report view or Data view.
Finding errors
Column quality
Turn on View > Column quality. Each column shows a bar with three percentages: Valid, Error, and Empty. Any non-zero Error value means you have work to do. Hover over the bar to open a menu with Keep Errors, Remove Errors, and Replace Errors.
Keep Errors to inspect rows
To see the whole row around an error, use Home > Keep Rows > Keep Errors (or Keep Errors from the column quality menu). This produces a table of only the rows with an error in the selected columns. Read these rows to identify the pattern, for example all values contain a currency symbol. Then delete that inspection step, or better, fix the cause earlier in the query.
Keep Errors, as a step, would look like this:
Table.SelectRowsWithErrors(ChangedType, {"Amount"})If you do not pass a column list, the function checks all columns.
Choosing a strategy
| Goal | Tool | Effect |
|---|---|---|
| Fix the cause | Clean the text first, set the locale | Value converts correctly |
| Drop bad rows | Remove Errors | Row is deleted |
| Substitute a value | Replace Errors | Cell gets a default |
| Investigate | Keep Errors | Only error rows remain |
Fixing the cause is usually best. Replacing or removing hides data problems, and replacing errors with 0 can distort totals.
Fixing the cause
Many conversion errors come from stray characters. Clean the text before changing the type. If Amount contains values like $1,200, replace the symbol first:
let
Source = #table({"Amount"}, {{"$1,200"}, {"350"}, {"abc"}}),
NoSymbol = Table.ReplaceValue(Source, "$", "", Replacer.ReplaceText, {"Amount"}),
ChangedType = Table.TransformColumnTypes(NoSymbol, {{"Amount", type number}}, "en-US")
in
ChangedTypeThe 1,200 converts to 1200 under en-US, because the comma is a thousands separator in that locale. The value abc still produces an error, which is correct: it is not a number.
The locale argument matters. With "de-DE", the comma is a decimal separator, so 1,200 becomes 1.2. Always set the locale to match the source.
Removing errors
Remove Errors deletes every row where the selected column has an error. Select the column first. If you select no column, nothing is selected to check, and the command uses the columns you highlighted, so confirm the selection before applying.
Table.RemoveRowsWithErrors(ChangedType, {"Amount"})Use this when the bad rows are not meaningful, such as trailing footer rows. Do not use it when each row represents a real transaction, because you lose that record and totals drop.
Replacing errors
Replace Errors keeps the row and swaps the error for a value you choose. Right-click the column header and choose Replace Errors, then type the value.
let
Source = #table({"Amount"}, {{"120"}, {"abc"}}),
ChangedType = Table.TransformColumnTypes(Source, {{"Amount", type number}}, "en-US"),
ReplacedErrors = Table.ReplaceErrorValues(ChangedType, {{"Amount", null}})
in
ReplacedErrorsReplace with null when the value is unknown. Replace with 0 only when zero is a true business meaning. Nulls are ignored by sums and averages in the model, while a 0 pulls an average down.
Replace Errors needs a column list. The second argument is a list of {column, replacement} pairs, so you can replace in several columns at once.
Order of steps matters
Errors are produced by the step that changes the type, so Replace Errors must come after that step. Putting it before has no effect, because no errors exist yet.
Replacement values must also fit the column type. Replacing errors in a number column with the text "n/a" makes the column mixed unless you change its type again. Use null or a number.
A related trap is Replace Values. It does not touch error cells. If you try to replace abc after the conversion, the cell is already an error and the value is gone. Do the replacement before the type change, or use Replace Errors after it.
A defensive pattern with try
When you write custom columns, you can catch errors inline with try ... otherwise:
let
Source = #table({"Revenue", "Units"}, {{100, 4}, {50, 0}}),
AddedPrice = Table.AddColumn(Source, "UnitPrice", each try [Revenue] / [Units] otherwise null, type nullable number)
in
AddedPriceThe second row divides by zero. In M, dividing a number by zero yields infinity rather than an error for typical numbers, so the result shows ∞. If you need a null there, test explicitly:
each if [Units] = 0 then null else [Revenue] / [Units]Use try ... otherwise for failures such as converting text with Number.From, where the failure is an actual error. Use an explicit if for cases you can predict.
Errors in a whole row versus a column
Errors can also hit an entire query. If the source file is missing or a column was renamed, you see a banner such as Expression.Error: The column 'Amount' of the table wasn't found. This is a step error, not a cell error, and Remove Errors does not apply. Open the failing step in Applied Steps, then correct the column name or path. For a recurring column rename in the source, handle it upstream or adjust the step.
Common mistakes
- Replacing errors with 0 by habit. This silently changes totals and averages.
- Trusting the preview. The sample may hide errors. Profile the entire data set.
- Removing errors before understanding them. Run Keep Errors first, and look for a pattern you can fix.
- Wrong step order. Replace Errors before the type change does nothing.
- Wrong locale. Dates and decimals turn into errors or, worse, into wrong values that raise no error.
The last point deserves care. A locale mismatch can produce a valid but wrong date, for example 03/04/2026 read as March 4 instead of April 3. Column quality will show 0% errors. Spot-check values after conversion.
Workflow summary
Renaming steps for clarity
Right-click a step and choose Rename to describe the decision, for example Dropped footer rows with errors. This changes only the step name in the M code, which becomes #"Dropped footer rows with errors". Descriptive names make refresh failures easier to diagnose.
Exercise
A column Amount shows 0% errors in the editor, but after loading, some cells in the report show errors. Name one likely reason and one fix.
Show answer
The editor profiled only the top 1,000 rows, so errors further down were not counted. Set Column profiling to "Based on entire data set," run Keep Errors to find the pattern, and fix the cause (for example, strip a currency symbol or set the correct locale) before the type change.
Exercise
You convert Amount to a number and apply Replace Errors with 0. Later, the average order value looks too low. Why, and what would you change?
Show answer
The error rows were turned into real zeros, which count in the average and pull it down. Replace the errors with null instead, since sums and averages ignore nulls, or remove the rows if they are not real orders.
Exercise
Write the M step that replaces errors in Amount with null, given a previous step named ChangedType.
Show answer
ReplacedErrors = Table.ReplaceErrorValues(ChangedType, {{"Amount", null}})