# Variables

### In Models:

Variables are defined at Model-level so that they can be used in any expression that is being created at the Mode-level. The list of all the variables defined for the Model is available in the variables section. You can edit/delete/add new variables to the list.

#### How to create variables in models

* Model -> Expressions Tab -> Expressions
* Click on add Expression.
* The expression box can be used to define a dimension/measure expression
* Variables can be created by clicking on add variable button.&#x20;
* You can see the output in the preview box after clicking on the “**Validate**” button. It shows the output of the expression applied on the first 5 rows of data.

**Model -> Expressions Tab -> Variables:**

* You can create new variables here(as shown below). This section also shows all the defined variables at the Model level, along with options to make edits and delete variables.&#x20;
* A variable defined in the variable section becomes a **global variable** in the context of that model, meaning that the variables can be used within any of the expressions in the same Model.

<figure><img src="/files/UPwmP9t7jTjbBK0Q8dC2" alt=""><figcaption><p>Variable Section</p></figcaption></figure>

### **In Reports**

The **run-time value** of the variables defined at the model level can be edited on the Reports-Edit Tab to get the desired output.

**In edit view:**

* The created variables can be seen in the left-hand side panel, where you can now find a tab with a variable icon along with Dimension and measure tabs.
* On Clicking the **Edit icon** on the created dimension/measure or the **Variable icon**, the **variable section** opens up.&#x20;
* The value of the variable can be controlled in real-time (as shown below). The value edited and saved **only applies to the Report** and *does not override* the default value of the variable at the Model level.

<figure><img src="/files/PGddCu8uF0KlG59W6YHo" alt=""><figcaption><p>Adding variables in report</p></figcaption></figure>


---

# 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://docs.sprinkledata.com/product/analysing-your-data/data-models/variables.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.
