Switch()

Format

Switch(InputValues ,Case1Value ,Case1Result ,Case2Value ,Case2Result [,OtherCases])

Returns

Returns the replacement value for each input value based on which cases were matched for each individual input value.

Inputs

InputValues: The input values that the function will compare to available cases and replace.
Behaviour: Required
Dimensions: Collection, SingleValue, MultiCollection
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
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
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

How to format data types

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 the last known value from {Tag2}, {Tag3} and {Tag4} for every 1, 2 or 3 value found in {Tag1}.

Release History

  • Switch() 4.6.5
    • Changed InputValues parameter to support MultiCollection values.
  • Switch() 4.5.1
    • Initial version

Comments are closed