Power BI Error Handling in Power Query
Error handling in Power Query for Power BI: step-level and cell-level errors and their common causes, what Remove, Replace and Keep errors do, try with otherwise and catch for custom logic, and a real example where changing one column's type would have turned 10% of the rows into errors that Remove errors deletes.
GloryTecks Team
Training & Placement Faculty
Last updated: 25 September 2026
Errors in Power Query are messages about your data. Some stop a refresh outright; others quietly turn individual cells into "Error". The tempting fix is to remove them and move on, which is sometimes right and sometimes deletes exactly the data the report needs. This guide covers the two kinds of error, the three built-in ways to handle cell errors, custom logic with try, and a real example of how a routine type change can create thousands of errors.
Two kinds of error
Microsoft distinguishes them clearly (Microsoft Learn: dealing with errors):
- Step-level errors stop the query from loading and show a yellow error bar with a reason, message and detail. Common examples are
DataSource.NotFound, when a file has moved or the user lacks access, and "The column ... of the table wasn't found", when a source column was renamed.Formula.Firewallerrors appear when combining sources with incompatible privacy levels. - Cell-level errors let the query load but show "Error" in individual cells. The most common cause is a data type conversion that fails, such as text "NA" in a column changed to Whole Number. Unsupported operations, such as combining text and a number without converting first, are another.
Step-level errors must be fixed at their cause: the path, the credentials, or the step that references a missing column. Microsoft's own example is a query that reads a file from one person's drive D and fails for a colleague who has no drive D; shared queries should read from locations everyone can reach. Cell-level errors need a decision about each one.
Finding cell errors
Turn on Column quality in the View tab of Power Query Editor. It shows the percentage of valid, error and empty values in each column, based on the preview rows by default; switch profiling to the entire data set when the preview might not contain the problems. Select the white space in an error cell to see its message.
How a routine type change creates errors, in numbers
Setting data types is one of the first steps in any query, and codes that look numeric are easy to mistype. Here is what would happen if a UK online retailer's invoice numbers and stock codes (UCI: Online Retail) were changed to Whole Number:
import io
import urllib.request
import zipfile
import pandas as pd
url = "https://archive.ics.uci.edu/static/public/352/online+retail.zip"
with zipfile.ZipFile(io.BytesIO(urllib.request.urlopen(url).read())) as archive:
raw = pd.read_excel(archive.open("Online Retail.xlsx"), dtype={"InvoiceNo": str, "StockCode": str})
revenue = raw["Quantity"] * raw["UnitPrice"]
for column in ["InvoiceNo", "StockCode"]:
as_number = pd.to_numeric(raw[column], errors="coerce") # what "Change type to Whole Number" would attempt
errors = raw.loc[as_number.isna(), column]
print(f"{column}: {len(errors)} conversion errors ({len(errors) / len(raw):.1%} of rows, "
f"{revenue[as_number.isna()].sum() / revenue.sum():.1%} of revenue)")
print(" most common failing values:", ", ".join(errors.value_counts().head(4).index))InvoiceNo: 9291 conversion errors (1.7% of rows, -9.3% of revenue)
most common failing values: C570867, C560540, C548460, C560855
StockCode: 54873 conversion errors (10.1% of rows, 8.5% of revenue)
most common failing values: 85123A, 85099B, POST, 85099Cfailing_codes = raw.loc[pd.to_numeric(raw["StockCode"], errors="coerce").isna(), "StockCode"]
print(f"failing stock codes that are digits plus a letter suffix: {failing_codes.str.match(r'^[0-9]+[A-Za-z]+$').mean():.1%}")
failing_invoices = raw.loc[pd.to_numeric(raw["InvoiceNo"], errors="coerce").isna(), "InvoiceNo"]
print("failing invoice numbers by first letter:", failing_invoices.str[0].value_counts().to_dict())failing stock codes that are digits plus a letter suffix: 94.5%
failing invoice numbers by first letter: {'C': 9288, 'A': 3}These are not bad data. The failing invoice numbers are almost all cancellations, marked with a "C" prefix, whose negative quantities offset 9.3% of revenue. The failing stock codes are overwhelmingly product variants such as 85123A. Clicking Remove errors after either type change would silently delete every cancellation, overstating sales, or a tenth of all product lines. The correct fix is not error handling at all: these columns are identifiers and should stay as text.
The three built-in options
When errors are genuine, Power Query offers three operations, each from the column's menu or the ribbon:
| Option | What it does | Use it when |
|---|---|---|
| Remove errors | Deletes rows with an error in the selected column | The rows are genuinely unusable and you have counted them |
| Replace errors | Puts a fixed value in place of each error | There is a defensible default, documented in the step name |
| Keep errors | Keeps only the rows with errors | Auditing: you want to see and share what failed |
Microsoft suggests Keep errors as an auditing tool. A useful habit is to create a reference query that keeps errors, load it to a hidden table or a separate report page, and check its row count after each refresh.
Custom logic with try, otherwise and catch
Power Query's equivalent of Excel's IFERROR is try ... otherwise (Microsoft Learn: error handling). In a custom column, it returns the value if the expression succeeds and the alternative if it fails:
try [Standard Rate] otherwise [Special Rate]For more control, try on its own returns a record with HasError, Value and Error fields, and the error record contains the reason, message and detail. The catch keyword applies logic to that record directly, for example using a fallback only for certain errors:
try [Standard Rate] catch (r) => if r[Message] <> "Invalid cell value '#REF!'." then [Special Rate] else nullA pattern that keeps problems visible is to add a flag column rather than hiding the error:
Table.AddColumn(Source, "Price check", each if (try Number.From([Price]))[HasError] then "Invalid price" else "OK")The flag can then be counted in a report, so errors become a data quality measure rather than a silent loss.
A policy for errors
- Fix causes first: wrong types, moved files and renamed columns.
- Count before you remove. Know how many rows and how much value an operation affects.
- Prefer flags to deletion, so problems remain measurable.
- Document any replacement value in the step name, such as "Replaced price errors with 0 (free samples)".
- Re-check after refresh: new source data brings new errors.
Data cleaning, step by step applies the same count-what-you-remove discipline outside Power BI, and the Power Query tutorial covers the transformations these steps sit among. When the same queries serve several models, handling errors once in a dataflow keeps the rules consistent.
What is the difference between a step-level and a cell-level error?
Is Remove errors safe?
What is the Power Query equivalent of IFERROR?
Why do errors appear only after publishing?
Data cleaning techniques and handling missing values in Power Query are part of the data transformation module of the Power BI course.
Sources
- Dealing with errors in Power Query (Microsoft Learn) — Microsoft Learn
- Error handling in Power Query (Microsoft Learn) — Microsoft Learn
- Online Retail (UCI Machine Learning Repository) — UCI Machine Learning Repository
GloryTecks Team
Training & Placement Faculty
The GloryTecks faculty team mentors learners across Data Science, AI and Data Engineering, with a focus on real-time projects and placement readiness in Hyderabad.
Want to master Power BI?
Join GloryTecks’ expert-led Power BI training in Hyderabad with real-time projects and 100% placement support.
Related articles
Power Query Tutorial: Transforming Data Without Code
A working tutorial for Power Query in Power BI Desktop: the applied-steps model, the profiling setting that hides problems, data types, the unpivot option that survives refresh, query folding, and how to structure queries so a report still refreshes next month.
Power BI Roadmap 2026: From Beginner to Job-Ready
A stage-by-stage Power BI roadmap from a first report to job-ready skills: preparing data, modelling, DAX, report design, publishing and security, then proof through projects, with a concrete checkpoint that shows when each stage is done, the role Microsoft describes for Power BI analysts, and common detours.
Power BI Projects to Build for Your Portfolio
Five Power BI portfolio projects, each proving a different skill (a star schema with time intelligence, performance on millions of rows, Power Query reshaping, row-level security and a report for a real user), with datasets you are allowed to publish and what a reviewer will check.