CASE
Allows the user to select a value depending on a series of value tests. There is no practical limit to the number of cases; however, for numerous cases, it is beneficial to list the most frequently encountered conditions first.
Syntax
@CASE (value, test_value1, test_result1
[, test_value2, test_result2] [, ...] [, default_result])
value
The column you are testing values for.
test_value1
The value to test against the value you are reading.
test_result1
The result to return.
default_result
The result returned when test_values are not entered.
Examples
Example 1
The following returns “A car” if PRODUCT_CODE is "CAR” and “A truck” if PRODUCT_CODE is "TRUCK”. In this case, if PRODUCT_CODE fits neither of the first two cases, a FIELD_MISSING indication is returned.
@CASE (PRODUCT_CODE, "CAR", "A car", "TRUCK", "A truck")
Example 2
In this modified case, assuming PRODUCT_CODE is neither "CAR” nor "TRUCK”, "A vehicle” is returned.
@CASE (PRODUCT_CODE, "CAR", "A car", "TRUCK", "A truck", "A vehicle")