ON THIS PAGE:
Format
SingleValueSwitch(InputValues ,Case1Value ,Case1Result ,Case2Value ,Case2Result [,OtherCases])
Returns
Returns the replacement value for the input value based on which case was matched for the input value.
Inputs
InputValues: The input value that the function will compare to available cases and replace.
Behaviour: Required
Dimensions: Collection, SingleValue
Valid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration
Case1Value: The value of the first case.
Behaviour: Required
Dimensions: SingleValue
Valid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration
Case1Result: The expression which will be (lazily) evaluated and used to replace the input value if it matched the value of this case.
Behaviour: Required
Dimensions: SingleValue
Note: Also supports a single string that contains an expression which returns a multi-collection variable, but a multi-collection of string is not supported.
Valid data types: String
Case2Value: The value of the second case.
Behaviour: Required
Dimensions: SingleValue
Valid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration
Case2Result: The expression which will be (lazily) evaluated and used to replace the input value if it matched the value of this case.
Behaviour: Required
Dimensions: SingleValue
Note: Also supports a single string that contains an expression which returns a multi-collection variable, but a multi-collection of string is not supported.
Valid data types: String
OtherCases: Subsequent cases must follow the existing pattern. I.e. even numbered parameters must contain possible values, odd numbered subsequent parameters must contain the expression which will be (lazily) evaluated and used to replace the input value.
Behaviour: ParamsArray
Dimensions: SingleValue
Valid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration
Examples
Expression: Switch(1 + 1, 1, "'case 1'", 2, "'case 2'", 3, "'case 3'")
Result: Returns the string "case 2".
Expression: Switch({Tag1}, 1, "{Tag2}", 2, "{Tag3}", 3, "{Tag4}")
Result: Returns all fetched values of {Tag2}, {Tag3} or {Tag4} depending on whether the fetched value of {Tag1} was 1, 2 or 3.
Release History
- SingleValueSwitch() 4.6.5
- Changed Case1Result and Case2Result parameters to support an expression containing a MultiCollection value.
- SingleValueSwitch() 4.5.1
- Initial version