iif

utility

Inline conditional expression (if-then-else)

Syntax

iif(condition, true_value, false_value)

Parameters

condition (boolean)

The condition to evaluate

true_value (any)

Value returned if condition is true

false_value (any)

Value returned if condition is false

Returns

any

Either true_value or false_value depending on the condition

Examples

Classify age as adult or minor
Input:
iif(.age >= 18, "adult", "minor")
Output:
"adult"
Input:
iif(.score > 50, "pass", "fail")
Output:
"pass"

The iif() function provides inline conditional logic, evaluating a condition and returning one of two values based on the result.

Usage

Use iif() for simple conditional transformations in data pipelines, replacing traditional if-else statements with a compact expression.

Related Functions