Tests an expression against a list of cases and returns the corresponding value of the first matching case.
SWITCH(expression, case1, value1, [case2,..], [value2,..] )
- expression - The value to be checked.
- case1 - The first case to be checked against expression.
- value1 - The corresponding value to be returned if case1 matches expression.
- case2, .. - [OPTIONAL] Additional cases to try if the previous ones don't match expression.
- value2, .. - [OPTIONAL] Additional values to be returned if their corresponding cases match expression.
SWITCH(C3,1,"One",2,"Two","No match") checks the value in cell C3. If the value is 1, the string "One" is returned. If the value is 2, the string "Two" is returned. Else, the string "No match" is returned.