SWITCH
The SWITCH function evaluates an expression against a list of values and returns the result corresponding to the first matching value. If no match is found, an optional default value is returned.
Syntax
SWITCH(expression, val1, res1, val2, res2, ..., val_n, res_n, default)Arguments
expression: The expression to evaluate.
val1, val2, … val_n: The values to compare against the expression.
res1, res2, … res_n: The result to return for each matching value.
default (Optional): The value to return if no match is found.
Return value
Returns the result corresponding to the first matching value. If no match is found, returns the default value (if specified).
Example
SWITCH(Sub-Category, "Bookcases", 4.55, "Chairs", 2.67, "Tables", 2.81, "Art", 1.35,
"Paper", 3.79, "Machines", 10.55, "Envelopes", 1.23, "Storage", 2.53, 0)Evaluates the Sub-Category value and returns the corresponding numeric value for each match; if no match is found, returns 0.

Excel equivalent
Last updated
Was this helpful?