Power Query handles errors in two layers. Data-level errors (a failed conversion, a missing column, a null that breaks a calculation) are caught by wrapping the step in try ... otherwise or by right-clicking a column and choosing Replace Errors. Query-level errors that stop a refresh are shown as a banner on the query in the editor, and you resolve them before you close and load. This guide walks through finding errors, isolating them into their own column, keeping a clean output, and stopping the same failure from coming back on the next refresh.
What You'll Need
- Power Query Editor, available in Excel (Data > Get Data), Power BI Desktop (Transform Data), and Power BI in the browser.
- A source you have permission to read, and the file or database path verified before you start.
- A column or two of plain text you can safely test on, if you want to practise before touching production queries.
- A copy of the query you can restore from, since some fixes require deleting steps.
Step-by-Step
- Open Power Query Editor. In Excel, select a cell in your table and go to Data > Get Data > Launch Power Query Editor. In Power BI Desktop, use Home > Transform Data. Menu labels vary slightly by version, device and region, so look for the closest match if a name reads differently on your build.
- Turn on error visibility. Go to View and check Column quality, Column distribution and, most importantly, Column profile. Then, in the status bar at the bottom of the window, confirm the profiling setting is set to profile the entire dataset rather than a sample. Column quality shows a small % Error figure per column, which is the fastest way to see whether you have a problem at all.
- Apply the correct data type at the source step. Errors usually appear immediately after Change Type. If the source step has a Changed Type step that was added automatically on connect, consider deleting it and setting types yourself, one column at a time, so you know exactly which conversion produced the failure.
- Read the actual message. Click the small error marker on a value; a preview shows the reason text plus the message. It shows something like DataFormat.Error: We couldn't convert to Number. Note the exact reason, because it determines the fix: a conversion problem, a missing field, a bad date, or a cascading error from an earlier step.
- Fix the root cause first. That means correcting the data, not hiding the error. Common real fixes: trimming and cleaning leading spaces before converting text to number, replacing comma decimal separators with a period when your locale expects one, changing a date column to a type that matches the actual format the source sends, and removing a merged header row that left a blank row at the top.
- Remove blank rows and clean before converting. Many conversion errors are just an empty string, a dash or a placeholder such as N/A in a text column. Use Transform > Replace Values to turn those markers into
null, then apply the numeric or date type. Nulls convert cleanly; text placeholders do not. - Kept the errors you cannot fix. Right-click the column header and choose Replace Errors to substitute a fallback value such as
0,nullor text like Unknown. This keeps the row and stops the refresh from breaking, but it hides the problem, so log the count first. - Count what you are about to lose. Right-click the column, then Remove Errors only when you have confirmed the offending rows should not be in the report. Add a separate query that keeps errors first, so you have a record. The safe pattern is to duplicate the query, use Keep Errors on the copy, and revisit that copy when the source fixes its data.
- Use
try ... otherwisefor deliberate fallback logic. In the formula bar, wrap the expression:try Number.From([Amount]) otherwise null. This returns a record with HasError, Value and Error if you use it bare, so reference the value withtry Number.From([Amount]) otherwise 0when you want a plain value. This is the clean way to do conditional cleaning inside a custom column. - Split error detail into its own column. Add a custom column with
try Text.From([Value]) otherwise null, then a second column withtry [Value] otherwise [Error][Message]to record the message text alongside a clean value column. Analysts who support a report for a long time almost always keep this pattern, because the message explains the failure faster than the value does. - Handle missing columns, not just missing values. If a source can drop a column, a hard step that references it breaks completely. Insert a guard step that checks whether the column exists before referencing it, using
Record.FieldOrDefaultorRecord.HasFieldson a row, and wrap the result intry ... otherwise. This turns a hard refresh failure into a value-level error you can report.
Common Mistakes
- Deleting the error rows first. Removing errors makes the preview look perfect and destroys the evidence. Count and record first, or keep the errors in a separate query.
- Replacing every error with zero. A zero total silently understates a report. Prefer null plus a visible count, so a missing value reads as missing rather than as a real zero.
- Fixing the symptom, not the type. Wrapping a whole table query in
try ... otherwisecatches one failure but hides every step after it. Apply the guard as close to the failing expression as possible. - Assuming a Step-level error means the data is wrong. A renamed source column produces a hard Expression.Error: The column 'X' of the table wasn't found. That is a schema change, not a value problem, and it needs the step updated.
- Trusting the sample. With profiling set to the top 1,000 rows, everything can look clean while row 40,000 fails. Switch to full-dataset profiling before you conclude the data is fine.
- Changing types in the app instead of the query. Applying types in the Excel sheet or the Power BI model does not fix Query; the conversion error appears upstream and stays.
Tips
- Name your query steps descriptively, and rename the step that fails. When an error message references Changed Type and you have six of them, you will waste time.
- Keep a dedicated Errors query per source. Duplicate the query, keep errors, and load it to a hidden sheet or a separate table. It costs nothing and answers the question "what was wrong last month?" without re-running anything.
- Use
try ... otherwiseon dates with a fallback null, then filter for nulls. That is quicker than reading through a huge column looking for red flags. - Sort or filter the error column itself. Errors show as a distinct type, so a quick filter for errors only isolates suspect rows in seconds.
- When a refresh fails after a source change, inspect the Applied Steps pane from the bottom up. The last step that previews without a warning is usually the culprit.
Troubleshooting
The query fails immediately on refresh with DataSource.Error. This is a connection problem, not a data problem: check the file path, credentials and whether the credentials have expired. Stay with the simplest checks first: re-enter the source settings, sign out and back in, and verify the path or the server name.
You get "The key didn't match any rows in the table". A column referenced in the M code no longer exists, usually because a header was renamed or the source changed shape. Delete the failing step and rebuild it, or rename the column in the source to match.
The error marker clears but the count stays wrong. You replaced errors with a value and the row is still in the total. Filter out the rows you replaced, or accept the fallback explicitly and label it in the report.
Errors appear only after you close and refresh. Open Power Query Editor again and re-run profiling on the full dataset. Preview rows are sampled, and a partial preview can make an inconsistent column type look healthy.
Nothing you change sticks. Confirm you pressed Close & Load rather than closing the window, and remember the fix applies to the query, not to data already loaded into the model, so refresh after closing.
Frequently Asked Questions
What is the difference between a value error and a step error?
A value error sits in one cell and shows as a red marker on that row, and the rest of the table still previews. A step error fails the whole step, so nothing after it renders. Use try ... otherwise to convert the second into the first where possible.
Can I see which rows contain errors without opening each one?
Yes: use Remove Errors on a duplicate query and Keep Errors on another, or filter the error column. Both isolate the failing rows without manual scanning.
Does try ... otherwise work in Excel as well as Power BI?
Yes, it is part of the M language itself, so it works wherever Power Query runs, including Excel and Power BI. The UI wording differs, but the formula is the same.
Should I replace errors with null or delete the rows?
Replace with null when the row matters and only one field is bad. Delete the row only when you have confirmed the record is invalid; deleting the whole row can drop other good data in it.
Why do fresh errors keep appearing on every refresh?
The source keeps sending inconsistent values. Fixing the query step hides the symptom; ask whoever owns the data to standardise the format, then tighten your query once the source is stable.