CHOOSE
Selects a value based on an index. Returns the item in a list, based on the index passed. If the index is too large it will return NULL.
Note that the index starts at 1 rather than 0.
Syntax
string CHOOSE(int? index, params string[] values)
int? CHOOSE(int? index, params int?[] values)
double? CHOOSE(int? index, params double?[] values)
object CHOOSE(int? index, params object[] values)
Example
If you wanted to return specific values for certain ProductID's then you can use the expression:
CHOOSE(ProductID, "One", "Two", "Three","Sausages")
This will return "One" for ProductID 1, "Two" for ProductID 2, "Three" for ProductID 3 and "Sausages" for ProductID 4.
If there was a ProductID 5 the function would return null
.
You can supply an array with all of the values to be returned by entering an array column instead of each item within the function:
CHOOSE(ProductID, MyProducts)