Skip to content

Filters

Filters add interactive controls to dashboards. Users can change filter values in the browser, and all queries that reference those filters re-execute automatically.

Filter Types

DAC supports three filter types:

Select

A dropdown with predefined or query-driven options.

yaml
filters:
  - name: region
    type: select
    default: "All"
    options:
      values: ["All", "North America", "Europe", "APAC"]

Multi-select:

yaml
  - name: status
    type: select
    multiple: true
    default: ["active", "pending"]
    options:
      values: ["active", "pending", "completed", "cancelled"]

Query-driven options:

yaml
  - name: customer
    type: select
    options:
      query: SELECT DISTINCT customer_name FROM orders ORDER BY 1
      connection: my_db

Date Range

A date picker with start and end dates. Supports presets for common ranges.

yaml
  - name: date_range
    type: date-range
    default: last_30_days

With specific presets:

yaml
  - name: date_range
    type: date-range
    default: last_90_days
    options:
      presets:
        - today
        - last_7_days
        - last_30_days
        - last_90_days
        - this_year

Text

A free-form text input.

yaml
  - name: search
    type: text
    default: ""

Available Date Presets

PresetDescription
todayCurrent day
yesterdayPrevious day
last_7_daysPast 7 days including today
last_30_daysPast 30 days including today
last_90_daysPast 90 days including today
this_monthFirst to last day of current month
last_monthFirst to last day of previous month
this_quarterFirst to last day of current quarter
this_yearJanuary 1 to December 31 of current year
year_to_dateJanuary 1 to today
all_time1970-01-01 to 2099-12-31

Using Filters in Queries

Filter values are injected into SQL via Jinja templating. Access them with filters.<filter_name>:

Select Filters

sql
SELECT * FROM orders
WHERE region = '{{ filters.region }}'

With an "All" option:

sql
SELECT * FROM orders
{% if filters.region != 'All' %}
WHERE region = '{{ filters.region }}'
{% endif %}

Date Range Filters

Date range filters provide .start and .end properties:

sql
SELECT * FROM orders
WHERE created_at >= '{{ filters.date_range.start }}'
  AND created_at <= '{{ filters.date_range.end }}'

Text Filters

sql
SELECT * FROM orders
WHERE customer_name LIKE '%{{ filters.search }}%'

Filter Fields Reference

FieldTypeRequiredDescription
namestringYesFilter identifier, used in filters.<name>
typestringYesselect, date-range, or text
multipleboolNoAllow multiple selections (select only)
defaultanyNoInitial value. String preset for date-range, array for multi-select
optionsobjectNoFilter options configuration
options.valuesstring[]NoStatic list of options (select)
options.querystringNoSQL to populate options (select)
options.connectionstringNoConnection for the options query
options.presetsstring[]NoWhich date presets to show (date-range)