> For the complete documentation index, see [llms.txt](https://docs.reorc.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.reorc.com/data-modeling/jinja-templating/variables.md).

# Variables

Variables can help configure time ranges, eliminate hardcoded values, or supply data for model configuration. In a ReOrc project, you can define variables as assets and use them across multiple models.

There are two scopes for variables in ReOrc:

* **Local variables** are defined in a model using Jinja syntax; they are scoped locally and only accessible within the model.&#x20;
* **Global variables** defined in **Library** > **Variables**, are project-level assets and accessible from any models in the project.&#x20;

When we refer to "variables" generally, we mean global variables.

Variables are defined with explicit types to remove the need for casting and prevent format errors. When building a model (whether in preview, console, or pipeline) that has variables, you can use pre-defined default values or overwrite them with custom inputs.

## Define a variable

To define a project variable, follow these steps:

1. In ReOrc, open your project and go to **Library** > **Variables**.
2. Click **+Add New**.
3. Provide the name, data type, description, and value for the variable.

   ReOrc supports creating project variables with explicit data types.

<figure><img src="/files/r34sNlCkoxJ0Y7JJInwm" alt=""><figcaption></figcaption></figure>

4. Click **Add**.

The new variable will be displayed in the **Variables** section of **Library**.

By default, a created variable is active and ready for use in models. You can deactivate the variable by toggling off the **Active** option.

## Use the variable

You can start referencing the defined variable in models with the `{{ var('variable_name') }}` expression.

For example, the following model uses the `min_order_dateime` defined in the project library.

```sql
select 
    id as order_id,
    customer as customer_id,
    ordered_at as order_date

from {{ source("jaffle_shop", "raw_orders") }}

where ordered_at >= {{ var('min_order_datetime') }}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.reorc.com/data-modeling/jinja-templating/variables.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
