Filters and variables¶
How do I add a filter (dropdown) to a dashboard?¶
Define it under variables: and reference it in each query's WHERE clause with {{ filter('column', variable_name) }}. Variables never filter anything on their own. See Variables.
How do I set the dropdown's options?¶
options.static for a fixed list, column: to read distinct values from a table column, or query: for custom SQL. See Variables.
How do I set a default value?¶
Set default: on the variable. Unset, it starts null and filter() applies no filter; a non-required select or multiselect already offers a clear-selection row back to that state, so you don't need to author an "All" option yourself. See UI Elements.
How do I add a date range picker?¶
input: daterange, then {{ filter_date_range('created_at', date_range) }} in the query. Date columns default to this input. See Date Range Filtering.
How do I make a filter apply to every chart?¶
Reference the variable in every query that should respond to it. Charts whose queries do not mention it are unaffected. See Wiring Variables to Queries.
How do I make one dropdown depend on another?¶
Source the second variable from a query that filters on the first. See Dependent Variables.
How do I set a filter from the URL?¶
Add it as a query parameter: /sales/?region=West. Every variable is settable this way, including hidden ones. See URL routing.
How do I hide a variable's control but keep using it?¶
Set visible: false on the variable. It can still be set from the URL or a link. See Variable.
How do I require a value before the dashboard renders?¶
Set required: true. The board asks for a value instead of rendering. See Variables.
How do I click a bar to filter the rest of the page?¶
Use link: with a query parameter for the variable, for example link: "?region={{ x }}". See In-page variable updates.
What input types are there?¶
select, multiselect, text, textarea, number, slider, datepicker, daterange, checkbox, and radio. See Variable UI Elements.