IFERROR

IFERROR(formula, error_branch)[source]

Returns the result of a formula, or a specified alternative value if an error occurs.

The IFERROR function evaluates the given formula. If the formula executes successfully, its result is returned. If an error occurs during evaluation, the value provided in error_branch is returned instead. This allows graceful handling of errors in model calculations without breaking the workflow.

Parameters:
  • formula (Operand) –

    The formula or model component to evaluate, which may produce an error.

    Supported types:

    • ANY

  • error_branch (Operand | int | float | str | bool) –

    The value to return if the formula evaluates to an error. If not of the same data type as formula, or NULL, a ValueError is raised.

    Supported types:

    • ANY

Return type:

Formula

Returns:

The result of the formula if no error occurs, otherwise the error_branch value.

Supported types:

  • ANY

Raises:
  • ValueError – If formula and error_branch have incompatible data types (unless one is NULL).

  • ValueError – If both formula and error_branch are NULL.

Examples

Basic usage with literals:

IFERROR(1 / 0, 0)
# Returns 0

Using formulas:

IFERROR(LOOKUP(my_table, "customer", "bob"), BLANK())
# Returns the customer record for "bob", or blank if not found