Filters allow users to interactively control the data displayed in your Intelligent App dashboards. They are linked to variables and can be referenced in SQL queries to dynamically filter results.

Filter Types

Datazone supports several filter types:
TypeDescription
textFree text input
numberNumeric input
dropdownSelect from a list of options
dateDate picker

Filter Configuration

Each filter is defined in the components.filters section of your YAML configuration. Key properties:
  • type: The filter type (text, number, dropdown, date)
  • name: Unique filter name
  • title: Label shown to users
  • affected_variable: The variable this filter updates
  • default_value: (Optional) Default value
  • options: (For dropdown) Static or SQL-driven options
  • multiple: (For dropdown) Allow multiple selections (true/false)
  • placeholder: (Optional) Placeholder text

Example: Static Dropdown Filter

- type: dropdown
  name: membership_type_filter_limited
  title: Membership Type
  affected_variable: membership_type_second
  default_value: 'all'
  options:
    type: static
    values:
      - value: all
        label: All
      - value: basic
        label: Basic
      - value: premium
        label: Premium
      - value: vip
        label: VIP

Example: SQL-Driven Dropdown Filter

- type: dropdown
  name: membership_type_filter
  title: Membership Type
  affected_variable: membership_type
  options:
    type: sql
    query: |
      SELECT distinct ProductGroup_Name FROM sales_order LIMIT 100;

Example: Date and Number Filters

- type: date
  name: order_date_filter
  title: Order Date Filter
  affected_variable: order_date
  default_value: '2024-04-01'

- type: number
  name: penalty_count_filter
  title: Penalty Count Filter
  affected_variable: penalty_count
  default_value: 10
  placeholder: 'Enter penalty count'

Using Filters in Queries

Filters update variables, which you can reference in your chart queries using double curly braces:
query: |
  select * from sales_order WHERE OrderDate > '{{ order_date }}' limit 100;

Handling Multiple Selection Filters

When working with dropdown filters that have multiple: true enabled, you’ll need to parse the selected values appropriately in your queries. The filter will provide an array of values that can be handled using Jinja’s template functions:
- type: dropdown
  name: region_filter
  title: Regions
  affected_variable: region_filter
  multiple: true
  options:
    type: static
    values:
      - value: North
        label: North Region
      - value: South
        label: South Region
      - value: East
        label: East Region
      - value: West
        label: West Region
You can then use the Jinja join filter to format these values correctly in your SQL:
query: |
  SELECT * FROM customer_data
  WHERE 1=1
  {% if region_filter %}
  AND CustomerRegion IN ('{{ region_filter | join("','") }}')
  {% endif %}
  LIMIT 100;
This will transform an array like ['North', 'South'] into the proper SQL format: 'North','South'.

Filter Dependencies

Filters can depend on other filters to create cascading filter effects. When one filter changes, dependent filters can update their options based on the selected value. This is particularly useful for hierarchical data like country/city relationships.

Example: Country and City Filters

In this example, the city filter’s options are limited based on the selected country:
filters:
  - type: dropdown
    name: country_filter
    title: Country
    affected_variable: selected_country
    default_value: 'USA'
    options:
      type: sql
      query: "SELECT DISTINCT country FROM locations ORDER BY country"

  - type: dropdown
    name: city_filter
    title: City
    affected_variable: selected_city
    options:
      type: sql
      query: |
        SELECT DISTINCT city FROM locations 
        WHERE 1=1
        {% if selected_country is defined %}
        AND country = '{{ selected_country }}'
        {% endif %}
        ORDER BY city

Key Points for Filter Dependencies

  • Use conditional logic with {% if variable_name is defined %} to check if a filter value exists
  • Always include a fallback condition (like WHERE 1=1) to ensure valid SQL when no filters are applied
  • Dependent filters will automatically refresh when their parent filter changes
  • You can chain multiple levels of dependencies (e.g., country → state → city)

Best Practices

  • Use descriptive titles and placeholders for better UX
  • Use SQL-driven dropdowns for dynamic option lists
  • Set sensible defaults to improve initial dashboard state
  • Group filters logically on tabs for clarity
See also: Intelligent Apps Overview, Chart Reference