> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlit.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Filters & Dynamic Bindings

> Learn how to make OpenLIT dashboards interactive by using filters and mustache-style dynamic bindings inside ClickHouse queries.

OpenLIT makes dashboards interactive by letting you add filters and dynamically bind their values to ClickHouse queries. This enables you to create reusable dashboards that respond to user inputs like time range, environment, region, and more.

## What are filters?

**Filters** are interactive controls (e.g. date ranges) placed at the top of a dashboard. You can bind these filters to your widgets so their values get passed into SQL queries in real time.

## What are dynamic bindings?

OpenLIT uses **mustache-style bindings** to inject filter values into your queries.

### Format:

```sql theme={null}
{{variable_name}}
```

At runtime, OpenLIT replaces each binding with the user-provided filter value.

### Common examples:

* `{{filter.timeLimit.start}}` and `{{filter.timeLimit.end}}` — for date range filters

## How to add and use filters

<iframe className="w-full aspect-video" src="https://www.youtube.com/embed/J9TFEWmVczI?list=PLgErWFh-dyiGp9yUDnnx67wHEeNqzzMXZ" title="How to use filters & dynamic bindings in OpenLIT – Create Interactive Dashboards with ClickHouse" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen />

## SQL example with mustache bindings

```sql theme={null}
SELECT
  toStartOfHour(event_time) AS time,
  count() AS value
FROM user_events
WHERE event_time BETWEEN {{filter.timeLimit.start}} AND {{filter.timeLimit.end}}
GROUP BY time
ORDER BY time
```

In this example:

* `{{filter.timeLimit.start}}` & `{{filter.timeLimit.end}}` are bound to a date range filter

## Supported filter types

* **Date Range** → `{{filter.timeLimit.start}}`, `{{filter.timeLimit.end}}`
* **(Coming soon)**: Dynamic filters etc

## Best practices

* Always use meaningful keys like `team_id`, `env`, or `region`
* Use `coalesce({{param}}, 'default')` to provide fallback values in ClickHouse
* Test your queries in the SQL editor with example values for clarity
* Avoid hardcoded constraints—use bindings to keep dashboards flexible
