SWITCH()

Choose-one conditional evaluation

Returns the results of an expression corresponding to the first matching value when evaluating one value against a list of values, or the results of the default expression if there is no match.

Syntax

SWITCH(value, expected-value1, expected-result1, [expected-value2, expected-result2...], default-result)

  • value - A value of any type.
  • expected-value - A value of any type. Must be comparable to value.
  • expected-result - An expression that is evaluated and returned if the associated expected-value is a match.
  • default-result - An expression that is evaluated and returned if no match is found.

Note: Every result expression should produce a value of the same type.

 

Was this helpful?
How can we improve it?
Search
Clear search
Close search
Google apps
Main menu
Search Help Center
false