Power Query does not have a literal IFERROR function like Excel, but it has the equivalent: the try ... otherwise expression in the M language. Wrapping a step or value in try ... otherwise lets your query keep loading instead of failing when a column is missing, a value is blank, or a conversion fails. This guide shows you exactly how to apply it in a custom column or in the Advanced Editor.

What You'll Need

  • Excel for Windows or Mac with Power Query built in (Data tab > Get Data), or Power BI Desktop
  • An existing query, or a table you can load into Power Query
  • Basic familiarity with the Power Query Editor window

Step-by-Step

  1. Open your workbook in Excel and select any cell in your source table, then go to Data > From Table/Range to load it into the Power Query Editor. (Menu labels can differ slightly between Excel versions and Power BI Desktop; the logic below is identical in both.)
  2. In the Power Query Editor, click Add Column > Custom Column. Give the column a name, such as "Safe Value".
  3. In the formula box, wrap the risky expression with try and otherwise. For example, to divide two columns safely:
    try [Revenue] / [Units] otherwise null
    This returns the division result when possible, and null instead of an error when [Units] is zero, blank, or the column does not exist.
  4. Click OK. The new column appears with no error cells; problem rows simply show null (or whatever fallback you chose).
  5. To replace errors with something more useful than null, change the fallback. For text: try [Revenue] / [Units] otherwise "Check data". For numbers: try [Revenue] / [Units] otherwise 0. The fallback must be a single value of the type you want.
  6. To protect an entire existing step instead of one column, open Home > Advanced Editor and wrap the step's expression:
    Sales = try Source{[Item="Sales",Schema="Item"]}[Data] otherwise #table({}, {})
    This stops a "column not found" or "key not found" error from breaking the whole query.
  7. Optionally, use try on its own to get a record describing the error. try [Revenue] / [Units] returns a record with either a Result field or HasError and Error fields, which you can expand into columns for auditing.
  8. Click Home > Close & Load to send the cleaned data back to Excel.

Common Mistakes

  • Typing iferror(...) in the formula bar. M has no IFERROR function; you must use try ... otherwise.
  • Forgetting that try only catches errors, not blanks or nulls. A null input returns null, not an error, so try [A] otherwise 0 still yields null when [A] is null. Handle nulls separately, for example if [A] = null then 0 else [A].
  • Leaving out otherwise and expecting a plain value. Bare try returns a record, which shows as a nested table-like cell until you expand it.
  • Applying the fallback to the wrong scope. try [A] + [B] otherwise 0 catches errors anywhere in the addition; wrap only the part you intend if you want partial results preserved.
  • Setting a fallback of the wrong type, e.g. otherwise "n/a" on a numeric column, then wondering why the column type is Any and later steps fail.

Tips

  • For whole-column cleanup without formulas, right-click the column and choose Replace Errors, then enter a replacement value. It is faster than a custom column when you want one fallback everywhere.
  • Combine null handling and error handling in one line: if [Units] = null then null else try [Revenue] / [Units] otherwise 0.
  • When merging queries, wrap the expand step in try ... otherwise if the source columns sometimes get renamed upstream.
  • Use the bare try record trick in a temporary audit column to see the actual error messages (in the Error field) instead of guessing what failed.
  • Keep your fallbacks consistent across queries so downstream pivots and formulas do not trip over mixed types.

Troubleshooting

The column still shows "Error". You probably wrapped only part of the expression, or the error occurs in a different step. Check the Applied Steps pane, click each step in turn, and find where the error first appears, then wrap that step.

The formula will not accept my typing. M is case-sensitive and uses square brackets for columns. Write [Column Name] exactly as shown in the column header, and use lowercase try and otherwise.

The custom column shows "Record" cells. You used try without otherwise. Either add an otherwise fallback or click the expand icon in the column header to drill into the record.

Errors return after refresh but not in the editor. The source data changed between sessions. Harden the query with try ... otherwise on the affected step, or fix the source data, then refresh again.

Everything else fails. Undo by deleting the custom-column step in Applied Steps, reload the source with Data > From Table/Range, and rebuild the column step by step.

Frequently Asked Questions

Is there an IFERROR function in Power Query?

No. Power Query's M language uses try ... otherwise instead. It does the same job: it catches an error and returns a fallback value you specify.

Can I return a blank instead of an error?

Yes. Use otherwise null for a true null, or otherwise "" for an empty text string. Null is usually the better choice because it is treated properly by filters and aggregations.

Does try ... otherwise catch nulls and blanks?

No. It only catches errors. A null passes through as null. Handle nulls with an if ... then ... else condition or by replacing values.

Can I use try on an entire table step?

Yes. In the Advanced Editor, wrap the step's expression in try ... otherwise and provide a fallback such as #table({}, {}) (an empty table) so the query still loads.

How is this different from Replace Errors?

Replace Errors is a point-and-click command that swaps errors in an existing column for one value. try ... otherwise is a formula you write, which gives more control, such as different fallbacks per expression or keeping the original error details.