Choose

The choose construction can be used to check a multitude of conditions and return the expression that is part of the first condition that evaluates to be true.

The full construction should be created as displayed in the syntax, starting with choose, ending with a default expression and the end keyword, and having 1 or more when ... then ... expressions in between.

The Choose construct in WEM is comparable to Case or Switch statements in some programming languages. See wikipedia.

This function is SQL compatible. For more information about SQL compatibility, see our documentation.

Syntax
/*basic syntax : */
choose
    when boolean_condition1 then value1
    when boolean_condition2 then value2
    when boolean_condition3 then value3
    when boolean_condition4 then value4
    when boolean_condition5 then value5
    default value
end

/*Example: */
choose
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 1 Then "Monday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 2 Then "Tuesday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 3 Then "Wednesday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 4 Then "Thursday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 5 Then "Friday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 6 Then "Saturday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 7 Then "Sunday"
    default "Day of the week"
end

Last updated

Was this helpful?