IFF

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Returns the first expression when condition is true and the second expression if it is false.

Syntax 

1iff(<condition>, <true_expr>, <false_expr>)

Arguments 

Required 

  • <condition>: Boolean condition to evaluate.
  • <true_expr>: Expression returned when condition is true.
  • <false_expr>: Expression returned when condition is false or NULL.

Returns 

Returns the selected expression. Result expressions must be convertible to a common type.

Considerations 

  • Requires a Boolean condition and exactly three arguments.
  • A NULL condition returns <false_expr>.
  • Compatible numeric result expressions can widen to a common type.

Examples 

Return the true expression 

Select the first result when condition evaluates to true.

1SELECT iff(TRUE, 'yes', 'no') AS result;

Returns yes.

Return the false expression for a NULL condition 

Select the false result when condition is NULL.

1SELECT iff(NULL, 'yes', 'no') AS result;

Returns no.

Related Documentation