Skip to main content

case

Evaluates multiple conditions and returns the value corresponding to the first condition that is true.

Syntax​

case(<if1>, <then1>, <if2>, <then2>, <if3>, <then3>, ...)
ParameterTypeDescription
if1BooleanThe first condition to evaluate.
then1anyThe value to return if first condition is true.
if2BooleanThe second condition to evaluate.
then2anyThe value to return if second condition is true.
if3Boolean
then3any

Return values​

Depends on input arguments.

Usage​

Categorizes orders as 'High', 'Medium', or 'Low' based on total price.

case(orders.total_price > 100, 'High', orders.total_price > 50, 'Medium', 'Low')