Advanced Excel Logical - SWITCH Function



Description

The 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. This function was added in Excel 2016.

Syntax

SWITCH (expression, value1, result1, [default or value2, result2],…[default or value3, result3])

Arguments

Argument Description Required/ Optional
expression Expression is the value that will be compared against value1…value126. Required
value1…value126 ValueN is a value that will be compared against expression. Required
result1…result126

ResultN is the value to be returned when the corresponding valueN argument matches expression.

ResultN and must be supplied for each corresponding valueN argument.

Required
Default

Default is the value to return in case no matches are found in the valueN expressions.

The Default argument is identified by having no corresponding result expression (see examples).

Default must be the final argument in the function.

Optional

Notes

  • As functions are limited to 254 arguments, you can use up to 126 pairs of value and result arguments.

  • If none of the value arguments match expression and no default argument is supplied, the SWITCH function returns the #N/A! error.

Applicability

Excel 2016

Example

Switch Function
advanced_excel_logical_functions.htm
Advertisements