# Switch

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.&#x20;

### Syntax

```
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.&#x20;
* **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.

> ### 📘
>
> 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

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

* Returns "One"

```
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*.&#x20;

```
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.*

<br>

<figure><img src="https://files.readme.io/f09d02a-2.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://files.readme.io/ca53b75-1.png" alt=""><figcaption></figcaption></figure>

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.meetuma.ai/uma-knowledgebase/data-and-reporting/analytics-pro/functions/logical-functions/switch.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
