Controls the flow of logic by executing certain statements if their 'case' matches the supplied input value.
- Returned Output: Variant
- Library: PQL \ Common \ Logical
- Version: 2020.12.000
- Can be combined with and other PQL function throughout the application.
- It CANNOT be used with MDX or VBA functions. But it can be used on MDX-based content in other parts of the application.
* Click on the function's arguments above for more details on the input values.
- The variable must be a numeric value.
- The case values (1 to 'n') need to be numeric and are compared to the variable value provided.
- A statement or expression is required for each case value (separated by a comma).
- The statements can evaluate to numeric values.
- The last statement is optional and does not need a case value. It will be the default expression if no cases match the variable.
- The statement expressions should return the same type of result: either numeric values (and data points), or sets. Mixing result types can lead to errors.
Different Function types
- See the implementation of Switch for semantic objects..
This example looks at the mathematical expression "4-2", and then looks at the various cases. The result is "bad", since it matches the "2"
switch(4-2, 1 “good”, 2, “bad”, “invalid”)