ID EN
#Logical

SWITCH

Excel Functions

Match multiple values, return first match

Syntax

EXCEL
=SWITCH(expression, val1/result1, [val2/result2], ..., [default])

Arguments

Parameter Description
expression The value or expression to match against.
val1/result1 The first value and result pair.
val2/result2 [optional] The second value and result pair.
default [optional] The default value to use when no match is found.

Return Value

Result corresponding with first match

Details

The SWITCH function compares one value against a list of values and returns a result that corresponds to the first match found. You can use the SWITCH function when you want to perform a "self-contained" exact match lookup with several possible results. When no match is found, SWITCH can return an optional default value. The first argument in SWITCH is called "expression" and can be a hard-coded constant, a cell reference, or a formula that returns a specific value to match against. Matching values and corresponding results are entered in pairs. SWITCH can handle up to 126 pairs of values and results. The last argument, default, is an optional value to return when there is no match. In the example shown, the formula in D5 is: SWITCH only performs an exact match, so you can't include logica

Examples

Example

In the example shown, the formula in D5 is:

EXCEL
=SWITCH(C5,1,"Poor",2,"OK",3,"Good","?")
Example

SWITCH only performs an exact match, so you can't include logical operators like greater than (>) or less than (

EXCEL
=SWITCH(TRUE,A1>=1000,"Gold",A1>=500,"Silver","Bronze")

See Also

IF IFS CHOOSE VLOOKUP MATCH