---
title: "SWITCH function in Excel: syntax and examples | PracticeExcel"
description: "How to use SWITCH in Excel 365 and Google Sheets: map codes to names without nesting IFs."
canonical_url: "https://practiceexcelonline.com/functions/switch"
locale: en
meta:
  "og:description": "How to use SWITCH in Excel 365 and Google Sheets: map codes to names without nesting IFs."
  "og:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~U1dJVENIIGZ1bmN0aW9uIGluIEV4Y2VsOiBzeW50YXggYW5kIGV4YW1wbGVz%2Cdescription_~SG93IHRvIHVzZSBTV0lUQ0ggaW4gRXhjZWwgMzY1IGFuZCBHb29nbGUgU2hlZXRzOiBtYXAgY29kZXMgdG8gbmFtZXMgd2l0aG91dCBuZXN0aW5nIElGcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U1dJVENIKGV4cHJlc3Npb24sIHZhbHVlMSwgcmVzdWx0MSwgW3ZhbHVlMiwgcmVzdWx0Ml0sIC4uLiwgW2RlZmF1bHRdKQ%2Cp_Ii9mdW5jdGlvbnMvc3dpdGNoIg%2Cs_vYG4qDujfKU_JndN.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "SWITCH function in Excel: syntax and examples | PracticeExcel"
  "twitter:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~U1dJVENIIGZ1bmN0aW9uIGluIEV4Y2VsOiBzeW50YXggYW5kIGV4YW1wbGVz%2Cdescription_~SG93IHRvIHVzZSBTV0lUQ0ggaW4gRXhjZWwgMzY1IGFuZCBHb29nbGUgU2hlZXRzOiBtYXAgY29kZXMgdG8gbmFtZXMgd2l0aG91dCBuZXN0aW5nIElGcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U1dJVENIKGV4cHJlc3Npb24sIHZhbHVlMSwgcmVzdWx0MSwgW3ZhbHVlMiwgcmVzdWx0Ml0sIC4uLiwgW2RlZmF1bHRdKQ%2Cp_Ii9mdW5jdGlvbnMvc3dpdGNoIg%2Cs_vYG4qDujfKU_JndN.png"
---

> Index of every page on this site: [llms.txt](https://practiceexcelonline.com/llms.txt)

# **The SWITCH function**

Compares one value against a list and returns the result for the first match, with an optional default at the end.

=

SWITCH(

## **Syntax**

```
SWITCH(expression, value1, result1, [value2, result2], ..., [default])
```

<dl><dt>**expression **</dt>
<dd>The value to compare.</dd>
<dt>**value1, result1 **</dt>
<dd>A value to match and the result to return for it.</dd>
<dt>**default **(optional)</dt>
<dd>What to return when nothing matches. Without it SWITCH returns #N/A.</dd></dl>

## **Examples**

C1`=SWITCH(<sup>1</sup>A2,<sup>2</sup>"DK",<sup>3</sup>"Denmark",<sup>4</sup>"SE",<sup>5</sup>"Sweden",<sup>6</sup>"Other")`

|  | A | B | C |
| --- | --- | --- | --- |
| 1 | Code |  | **Denmark** |
| 2 | DK |  | |

**In plain words:** Look at <sup>1</sup>the code in A2: <sup>2</sup>if it is DK, <sup>3</sup>show Denmark; <sup>4</sup>if it is SE, <sup>5</sup>show Sweden; <sup>6</sup>otherwise show Other.

C1=SWITCH(A2,"NO","Norway","Other")

|  | A | B | C |
| --- | --- | --- | --- |
| 1 | Code |  | **Other** |
| 2 | DK |  | |

## **Read the guide**

- [**Excel IF formulas: from one condition to many**](https://practiceexcelonline.com/learn/excel-if-function)

## **Related functions**

- [**IFS**](https://practiceexcelonline.com/functions/ifs)
- [**IF**](https://practiceexcelonline.com/functions/if)
- [**CHOOSE**](https://practiceexcelonline.com/functions/choose)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://practiceexcelonline.com/#identity","@type":"Organization","name":"PracticeExcel","url":"https://practiceexcelonline.com/","logo":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/#website","@type":"WebSite","inLanguage":"en-US","name":"PracticeExcel","url":"https://practiceexcelonline.com/","alternateName":["Practice Excel Online","PracticeExcelOnline.com"],"publisher":{"@id":"https://practiceexcelonline.com/#identity"},"workTranslation":{"@id":"https://excelopgaver.dk/#website"}},{"@id":"https://practiceexcelonline.com/functions/switch#webpage","@type":"WebPage","description":"How to use SWITCH in Excel 365 and Google Sheets: map codes to names without nesting IFs.","name":"SWITCH function in Excel: syntax and examples","url":"https://practiceexcelonline.com/functions/switch","breadcrumb":{"@id":"https://practiceexcelonline.com/functions/switch#breadcrumb"},"isPartOf":{"@id":"https://practiceexcelonline.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://practiceexcelonline.com/functions/switch"]}],"primaryImageOfPage":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/functions/switch#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://practiceexcelonline.com","position":1},{"@type":"ListItem","name":"Excel functions","item":"https://practiceexcelonline.com/functions","position":2},{"@type":"ListItem","name":"SWITCH function in Excel: syntax and examples","position":3}]},{"@id":"https://practiceexcelonline.com/functions/switch#article","description":"How to use SWITCH in Excel 365 and Google Sheets: map codes to names without nesting IFs.","headline":"SWITCH function in Excel: syntax and examples","inLanguage":"en-US","thumbnailUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~U1dJVENIIGZ1bmN0aW9uIGluIEV4Y2VsOiBzeW50YXggYW5kIGV4YW1wbGVz%2Cdescription_~SG93IHRvIHVzZSBTV0lUQ0ggaW4gRXhjZWwgMzY1IGFuZCBHb29nbGUgU2hlZXRzOiBtYXAgY29kZXMgdG8gbmFtZXMgd2l0aG91dCBuZXN0aW5nIElGcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U1dJVENIKGV4cHJlc3Npb24sIHZhbHVlMSwgcmVzdWx0MSwgW3ZhbHVlMiwgcmVzdWx0Ml0sIC4uLiwgW2RlZmF1bHRdKQ%2Cp_Ii9mdW5jdGlvbnMvc3dpdGNoIg%2Cs_vYG4qDujfKU_JndN.png","@type":["Article","TechArticle"],"author":{"@id":"https://practiceexcelonline.com/#identity"},"image":{"@id":"https://practiceexcelonline.com/#/schema/image/1"},"isPartOf":{"@id":"https://practiceexcelonline.com/functions/switch#webpage"},"mainEntityOfPage":{"@id":"https://practiceexcelonline.com/functions/switch#webpage"},"publisher":{"@id":"https://practiceexcelonline.com/#identity"}},{"@id":"https://practiceexcelonline.com/#logo","@type":"ImageObject","caption":"PracticeExcel","contentUrl":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png"},{"@id":"https://practiceexcelonline.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~U1dJVENIIGZ1bmN0aW9uIGluIEV4Y2VsOiBzeW50YXggYW5kIGV4YW1wbGVz%2Cdescription_~SG93IHRvIHVzZSBTV0lUQ0ggaW4gRXhjZWwgMzY1IGFuZCBHb29nbGUgU2hlZXRzOiBtYXAgY29kZXMgdG8gbmFtZXMgd2l0aG91dCBuZXN0aW5nIElGcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U1dJVENIKGV4cHJlc3Npb24sIHZhbHVlMSwgcmVzdWx0MSwgW3ZhbHVlMiwgcmVzdWx0Ml0sIC4uLiwgW2RlZmF1bHRdKQ%2Cp_Ii9mdW5jdGlvbnMvc3dpdGNoIg%2Cs_vYG4qDujfKU_JndN.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~U1dJVENIIGZ1bmN0aW9uIGluIEV4Y2VsOiBzeW50YXggYW5kIGV4YW1wbGVz%2Cdescription_~SG93IHRvIHVzZSBTV0lUQ0ggaW4gRXhjZWwgMzY1IGFuZCBHb29nbGUgU2hlZXRzOiBtYXAgY29kZXMgdG8gbmFtZXMgd2l0aG91dCBuZXN0aW5nIElGcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U1dJVENIKGV4cHJlc3Npb24sIHZhbHVlMSwgcmVzdWx0MSwgW3ZhbHVlMiwgcmVzdWx0Ml0sIC4uLiwgW2RlZmF1bHRdKQ%2Cp_Ii9mdW5jdGlvbnMvc3dpdGNoIg%2Cs_vYG4qDujfKU_JndN.png"}]}
```

## Sitemap

See the full [sitemap](https://practiceexcelonline.com/sitemap.md) for all pages.
