Description
Returns the value from the case string that matches the given expression. If no case matches the given expression, a default value can be defined.
Syntax
SELECTCASE ( expression,
"operator1~result1 | operator2~result2 | operatorN~resultN | Else~resultDflt" )
Parameter | Description | ||||||
---|---|---|---|---|---|---|---|
expression | Expression to be evaluated. | ||||||
case string |
A collection of parameters defining each case.
Within the case string:
|
Examples
The following statement examines the value of S1. If S1 equals 1 the function returns A, if the value is 2 the function returns B, and if the value is 3 the function returns C.
SELECTCASE(S1, "=1~A | =2~B | =3~C")
The following statement adds a default value to return if no value matches S1 the function.
SELECTCASE(S1, "=1~A | =2~B | =3~C | ELSE~#NULL!")
The following statement performs the same comparisons as above, using a field reference within the case string.
SELECTCASE(S1, "=1~A | =2~B | =3~" &S2& "| ELSE=#NULL!")