> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# Switch

> Use the Sigma Switch function to return the result corresponding to the first matching value.

The **Switch** function returns the result corresponding to the first matching value. If the **case** argument evaluates to True, then the corresponding result is returned, otherwise the **else** argument is returned.

## Syntax

```sigma
Switch(value, case 1, result 1, [case 2], [result 2], ... , [else])
```

* **value** (required) The value to test.
* **case 1** (required): The case to test the value against.
* **result 1** (required): The result to be returned if its preceding case matches the input value.
* **case 2+, result 2+** (optional): Several pairs can be listed in a single function. Every supplied case must have a corresponding result.
* **else** (optional): The result to be returned if no cases match the value.

> **Info**
>
> If no **else** condition is supplied, a Null result is returned when no cases are met.
>
> The **result(s)** argument must be of the same data type. #1 below will not work because the function is asked to return a string OR a number, whereas #2 will work because both outputs are strings.

1. `Switch([Number Column], 1, [String Value], 2, [Numeric Value])`
2. `Switch([Number Column], 1, [String Value], 2, [String Value])`

## Example

```sigma
Switch(1, 0, "None", 1, "One", "Many")
```

* Returns "One"

```sigma
Switch(2, 0, "None", 1, "One", "Many")
```

* Returns "Many"

A table contains Sales Revenue data that is grouped by a *Switch* column (i.e., dynamic dimension field) and *Month*.

```sigma
Switch([dimension-param], "Product Family", [Product Family], "Product Type", [Product Type])
```

* With a single-select list parameter whose control id is `[dimension-param]`, you can can use the Switch function to return monthly Sales Revenue data by *Product Family* or *Product Type.*

![Workbook with the dimension control set to Product Family and a table grouped by the selected dimension and month.](/_fern-img/4197a61e3f1463b7674ca59accf33df709dac111f5d634a8c37af22234142463.webp)\
![Line chart titled Revenue by Product Dimension and Month, with monthly revenue series for product categories selected by the Switch control.](/_fern-img/05425509e19913eac03e7f8bce27ef042a8b7d18abbc12e2d1d2e2be489eafff.webp)

## Related resources

* [If](/docs/if)