# SWITCH Function

> Compare a value with a list of cases and return the matching result with SWITCH in TX Sheet Control: case pairs, the default value and #N/A.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Function
- **Path:** TX Sheet Control > API Reference > Formula Functions > SWITCH Function
- **213 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/switch/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/switch/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/switch/llms-full.txt

---

Compare a value with a list of cases and return the result of the first match. `test_or_expression` is compared with each `test_or_case` in turn, and SWITCH returns the `result` that follows the first equal case. A last argument without a pair is the default, returned when no case matches; without a default, no match returns `#N/A`.

### Syntax

```text
SWITCH(test_or_expression, result, test_or_case, result)
```

Category: Logical. Minimum arguments: 2. Maximum arguments: 255.

Available for supported offline calculation.

### Examples

```text
=SWITCH(FALSE,1,TRUE,2)
```

The formula returns 2, the result of the case TRUE.

Cell and range examples require appropriate input values in the referenced cells. Handle invalid arguments, formula errors and array and spill constraints.

### See Also

- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)
- [Custom Functions and Formula Data](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/custom-functions/llms-full.txt)

---

## Nearby

- **Previous:** [SUMXMY2 Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/sumxmy2/llms-full.txt)
- **Next:** [SYD Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/syd/llms-full.txt)
