X
Excel Zero to Hero Interactive Learning Platform
0%
logical

SWITCH Function

intermediate

SWITCH Function

🎯Purpose

Evaluates one value (called the 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

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

Arguments Breakdown

Argument Required? Description
expression Required The value or reference to be compared against val1, val2, etc.
val1 Required A value that is compared against expression.
result1 Required The corresponding result to be returned when val1 matches expression.
default Optional A value to return if no matches are found. If omitted and no match is found, #N/A is returned.

Practical Examples

1. Currency Code Expansion

From Formulas_&_Functions_Part_2.xlsx (Sheet Logical ):

EXCEL
=SWITCH(A2,
    "USD", "US Dollar",
    "EUR", "Euro",
    "EGP", "Egyptian Pound",
    "SAR", "Saudi Riyal",
    "Other Currency"
)

2. Department ID Mapping

EXCEL
=SWITCH(DeptID, 1, "Sales", 2, "Marketing", 3, "Finance", "General")

SWITCH vs IFS

  • IFS tests multiple different boolean expressions: =IFS(A1>100, "High", B1="Yes", "Approved").
  • SWITCH evaluates a single expression against exact values: =SWITCH(Status, "O", "Open", "C", "Closed"). It avoids repeating the variable name in every condition.

Related Knowledge

← Back to Formula Library