SWITCH

Tests an expression against a list and returns a result that corresponds with either the first matching value or an optional default value if there is no match.

Usage examples 

SWITCH(1 + 1, 1, "one", 2, "two", "other")

Syntax 

SWITCH ( expression, case1, [ case2, ... ], [ default ] )

  • expression - an expression for any valid values.

  • case1 - case1 to be tested against.

  • case2 - case1 to be tested against.

  • default - An optional value, specified as the last parameter, to be returned if none of the cases match the expression.

Returns 

any - an optional last parameter to return if none of the cases match the expression.

Functions reference