Skip to main content
← All functions

SWITCH function

Evaluates an expression against a list of values and returns the result corresponding to the first matching value. If there is no match, an optional default value may be returned.

Syntax

SWITCH(expression, value1, result1, [default_or_value2], [result2])

Square brackets indicate optional arguments.

Arguments

ArgumentRequiredMeaning
expressionYesExpression is the value (such as a number, date or some text) that will be compared against value1…value126.WEEKDAY(A2)
value1YesValueN is a value that will be compared against expression.1
result1YesResultN is the value to be returned when the corresponding valueN argument matches expression. ResultN and must be supplied for each corresponding valueN argument."Sunday"
default_or_value2No · repeatsDefault is the value to return in case no matches are found in the valueN expressions. The Default argument is identified by having no corresponding resultN expression (see examples). Default must be the final argument in the function.2
result2No · repeatsResultN is the value to be returned when the corresponding valueN argument matches expression. ResultN and must be supplied for each corresponding valueN argument."Monday"

Try SWITCH

Translate a region into a short code

=SWITCH(C2,"East","E","Other")

Translate a region into a short code. The result is checked against a separately authored expected value for the supplied table. You can edit the data to explore the rule.

Inspect the current formula

Read its written arguments or observe actual operation values in a separate local calculation. This action neither applies a draft nor grades an answer.

Read the formula, one argument at a time

Explore the written function calls and their inputs. The calculation result belongs to the complete formula.

SWITCH · top-level call

=SWITCH(C2,"East","E","Other")

1 / 4 · expression

Expression is the value (such as a number, date or some text) that will be compared against value1…value126.

SWITCH reference ↗

Follow the cells behind a result

Read explicit local references and helper formulas using a separate calculation. Your draft stays in this field; the worksheet and practice checks do not change.

The worksheet runs locally. Published checks apply to the supplied example only. Native Excel and Google Sheets compatibility remain unverified.

Reference and compatibility

Univer 1.0.4 / Apache-2.0. Calculation checks cover the supplied examples only. The browser worksheet does not implement every Excel feature, external service or connected data type.