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:
- Return type:
- Returns:
The result of the formula if no error occurs, otherwise the error_branch value.
- 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
``value`` — accepted types
BOOLEAN
BOOLEAN_ARRAY
BOOLEAN_MAP
DATE
DATETIME
DATETIME_ARRAY
DATETIME_MAP
DATE_ARRAY
DATE_MAP
DECIMAL
DECIMAL_ARRAY
DECIMAL_MAP
INTEGER
INTEGER_ARRAY
INTEGER_MAP
NULL
OBJECT
OBJECT_ARRAY
STRING
STRING_ARRAY
STRING_MAP
TIME
TIME_ARRAY
TIME_MAP
``blank_branch`` — accepted types
BOOLEAN
BOOLEAN_ARRAY
BOOLEAN_MAP
DATE
DATETIME
DATETIME_ARRAY
DATETIME_MAP
DATE_ARRAY
DATE_MAP
DECIMAL
DECIMAL_ARRAY
DECIMAL_MAP
INTEGER
INTEGER_ARRAY
INTEGER_MAP
NULL
OBJECT
OBJECT_ARRAY
STRING
STRING_ARRAY
STRING_MAP
TIME
TIME_ARRAY
TIME_MAP
Return types
BOOLEAN
BOOLEAN_ARRAY
BOOLEAN_MAP
DATE
DATETIME
DATETIME_ARRAY
DATETIME_MAP
DATE_ARRAY
DATE_MAP
DECIMAL
DECIMAL_ARRAY
DECIMAL_MAP
INTEGER
INTEGER_ARRAY
INTEGER_MAP
OBJECT
OBJECT_ARRAY
STRING
STRING_ARRAY
STRING_MAP
TIME
TIME_ARRAY
TIME_MAP