OpenBI Docs Buy

IFERROR

An expression's value, or another value when it gives an error (an infinite number counts as one).

Group: Logical. Compatible with DAX.

Syntax

IFERROR ( <value>, <value_if_error> )
ParameterTypeDescription
valueValueThe expression to try.
value_if_errorValueThe result when the expression fails.

Returns

Same type as its values. The expression's value, or value_if_error when it fails.

Remarks

  • Dividing by zero is not an error in OAX: it gives infinity, or NaN for 0 / 0. IFERROR counts both as errors, as Power BI does.
  • A blank is not an error: IFERROR ( BLANK (), 0 ) is blank.
  • For a division, DIVIDE ( a, b, alternate ) says the same more plainly; for blanks, COALESCE.
  • Comparing values that cannot be compared, a number with a text, stops the query before IFERROR has a chance to catch it.

Examples

What counts as an error

EVALUATE
ROW (
    "1 / 0", IFERROR ( 1 / 0, -1 ),
    "0 / 0", IFERROR ( 0 / 0, -1 ),
    "Text as a number", IFERROR ( VALUE ( "abc" ), -1 ),
    "5", IFERROR ( 5, -1 ),
    "Blank", IFERROR ( BLANK (), -1 )
)
1 / 00 / 0Text as a number5Blank
-1-1-15(blank)

Codes that may not be numbers

EVALUATE
VAR Codes = DATATABLE ( "Code", STRING, { { "12" }, { "40" }, { "n/a" } } )
RETURN
    ADDCOLUMNS ( Codes, "Number", IFERROR ( VALUE ( [Code] ), BLANK () ) )
CodeNumber
1212
4040
n/a(blank)

ISERROR, DIVIDE, COALESCE, ERROR, VALUE.

Last updated · OpenBI Studio 0.3.74