---
title: SWITCH
url: https://www.tines.com/docs/formulas/functions/switch/
kind: formula-function
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/llms.txt) › [Formulas](https://www.tines.com/llm/docs/formulas.md) › [Functions](https://www.tines.com/llm/docs/formulas/functions.md)*

# SWITCH

*[View on tines.com](https://www.tines.com/docs/formulas/functions/switch/)*

Compares the input expression against a list of values and returns the corresponding result for the listed value upon first match. If no match is found, the default values is returned.

**Categories:** Logic

## Syntax

```
SWITCH(expression, value_to_compare, value_to_return, ..., default_value)
```

## Examples

### Example 1

Formula:

```
SWITCH(1+1, 2, 'true!', 1, 'false!', 'error!')
```

Output:

```json
"true!"
```

### Example 2

Input:

```json
{
  "day_of_week": "sunday"
}
```

Formula:

```
SWITCH(day_of_week, 'monday', 'working', 'saturday', 'weekend', 'error')
```

Output:

```json
"error"
```

### Example 3

Input:

```json
{
  "status": "approved"
}
```

Formula:

```
SWITCH(status, 'pending', 'yellow', 'approved', 'green', 'rejected', 'red', 'gray')
```

Output:

```json
"green"
```

### Example 4

Input:

```json
{
  "score": "F"
}
```

Formula:

```
SWITCH(score, 'A', 'Excellent', 'B', 'Good', 'C', 'Average', 'Needs Improvement')
```

Output:

```json
"Needs Improvement"
```
