CHOOSEBYVAL

Syntax

CHOOSEBYVAL (expression, value1, result1, value2, result2,..., defaultresult)

Description

Evaluates a list of values and returns the result associated with the first value that is equal to the expression. If no value is matched, the default result is returned.

Arguments

expression Any expression.
valuen Item compared to the expression when seeking a match.
resultn Result returned if the function finds a match when comparing values.
defaultresult Optional result to be returned if no match is found.

Returns

The result corresponding to the value that is equal to the expression. If no values are matched, the defaultresult is returned. If no defaultresult is specified, a record error is returned.

An optional single default result at the end of the list is the default, if none of the values is a match.

Remarks

Multiple value/result pairs can be provided in the list.

Any of the parameters in the syntax above can be an expression. Expressions are evaluated only when none of the prior conditions are met.

Examples

CHOOSEBYVAL(2,"1", "Paris", "2", "London","3", "Rome", "New York")

Returns: London

CHOOSEBYVAL(7,"1", "Paris", "2", "London","3", "Rome", "New York")

Returns: New York

Related Topics

Data Conversion

CHAR

CHOOSE