case

Returns the result of multiple if statements.

Example

Check COUNTRYNAME_ for instances of “Spain” and “Argentina”. For “Spain”, return “Great”. For “Argentina”, return “Cool”. If COUNTRYNAME_ evaluates to neither “Spain” nor “Argentina”, return “Other_Country”.

case(SALES.COUNTRIES.COUNTRY_NAME = "Spain", "Great", SALES.COUNTRIES.COUNTRY_NAME = "Argentina", "Cool", "Other_Country")

Syntax

case(bool expr1, result1, bool expr2, result2, . . ., bool exprN, resultN, else)

Parameters

  • exprN : expression returning bool
  • resultN : expression to evaluate and return if exprN evaluates to true
  • else : expression to evaluate and return if none of exprN evaluate to true

    Returns

    <type> expression

Notes

Function case returns an a value dependent on which of its test conditions are satisfied. For a pair of expressions (say, the first and second) case evaluates the first and returns the second if the evaluation is true. If it is not true, case tries the same thing with the second pair. This continues until a match is found. If there is no match, case returns the final expression (else).


© Incorta, Inc. All Rights Reserved.