Dashboard Filter > Raw SQL Query Variable
Learn how to create a Raw SQL Query Variable filter in Draxlr to pass dashboard filter values into variables in your raw SQL queries, with multi-value and date range support.
Raw SQL Query Variable filters allow you to dynamically pass values into variables defined in your Raw SQL queries.
This is particularly useful when you want your dashboards to react to user-selected values, making them more interactive and customizable.
Unlike Standard Filters, which filter data based on column values, Raw SQL Query Variable Filters only work with raw SQL queries that contain variables.

First up, click on "Add Filter".
How to create?
1. Click on Add Filter
From your dashboard, click the Add Filter button in the top bar.
2. Select Raw SQL Query Variable
In the filter type options, choose Raw SQL Query Variable.
3. Enter a Filter Name
Provide a descriptive name for your filter (e.g., Employee ID).
4. Choose a Data Type
Select the appropriate Data Type for the filter (Text, Numeric, Boolean, Date & Time, Date, Time).
This ensures values match the variable type in your Raw SQL query.
5. Allow Multiple Values or Use Date Range
-
Allow multiple values (Text and Numeric): enable this option if your SQL query uses operators such as
IN,NOT IN, etc.SELECT * FROM `Orders` WHERE `Orders`.`EmployeeID` IN ({{employeeId}}); -
Use date range (Date and Date & Time): enable this option to let users pick a start and end date instead of a single value. See Filtering by a date range below.
6. Map the Filter to a Query Variable
From the dropdown, select the variable in your Raw SQL query where the filter value should be passed. For a date range filter, only {{dateRange:<field name>}} variables are listed.
7. Create the Filter
Click Create to save the filter.
8. Apply the Filter
Your filter will now appear in the dashboard sidebar. Enter a value and apply it.
9. See Results
The filter’s value will be dynamically passed into the Raw SQL variable, updating the connected dashboard elements instantly.
Filtering by a Date Range
Turn on Use date range to filter dashboard elements between a start and an end date. The option appears when the filter’s data type is Date or Date & Time.
Your queries need a date range variable:
Date range filters only work with queries that use
{{dateRange:<field name>}}, where <field name> is the date column to
filter on. A regular variable such as {{orderDate}} can’t receive a range.
For example, this saved query filters orders by their OrderDate:
SELECT * FROM `Orders`
WHERE {{dateRange:OrderDate}};
To keep the element working when the filter isn’t applied, wrap the condition in an optional section:
SELECT * FROM `Orders`
WHERE 1 = 1
[[AND {{dateRange:OrderDate}}]];
When creating the filter:
- Select the Date or Date & Time data type.
- Turn on Use date range.
- For each dashboard element, select its
dateRange:<field name>variable. Variables of other types are not listed.
On the dashboard, the filter opens a date range picker with presets such as This Week and Last Month. The selected range is applied to the field in every connected element. Learn more about the syntax in Raw SQL.
Key Notes
- Works only with Raw SQL queries containing variables.
- Variables must match the filter’s data type (e.g., numeric for IDs, text for names).
- Date range filters need
{{dateRange:<field name>}}in the query.
✅ That’s it! You’ve successfully created a Raw SQL Query Variable Filter.
