AML FilterBlock
A grasp of these concepts will help you understand this documentation better:
FilterBlock adds a user-controlled filter to the dashboard. Viewers interact with it to narrow down the data shown in connected visualization blocks, or to limit the values suggested on another filter block. Either way, it's wired up via a FilterInteraction.
block <name>: FilterBlock {
label: 'Filter Label'
description: '' // optional
type: 'field' // or: 'text' / 'number' / 'date' / 'truefalse'
source: FieldFilterSource { ... } // optional, only for type: 'field'
default { // optional
operator: '...'
value: '...'
}
settings { ... } // optional
theme: BlockTheme { ... } // optional
}
Parameters
| Parameter | Description |
|---|---|
label | Display name shown on the filter control. |
description | Optional description. Supports Markdown. |
type | Filter type: 'field', 'text', 'number', 'date', 'truefalse'. See Filter Types for what each type does. |
source | A FieldFilterSource specifying which field the filter controls. Only used when type is 'field'. |
default | Optional default filter condition applied when the dashboard loads. See default. |
settings | Display and drill-through settings for the control. |
theme | Optional BlockTheme override for visual styling. |
FieldFilterSource
FieldFilterSource points to the field the filter controls. Field filters are recommended when all your dashboard's viz blocks come from the same dataset: they support value suggestions and automatic mapping. See Field filters.
| Parameter | Description |
|---|---|
dataset | The dataset name. |
field | Reference to the field using r(model.field) syntax. |
default
The default block sets the initial filter state when the dashboard loads.
| Parameter | Description | Accepted values |
|---|---|---|
operator | How to apply the filter | 'is', 'is_not', 'contains', 'does_not_contain', 'starts_with', 'ends_with', 'is_null', 'not_null', 'matches_user_attribute', 'top', 'bottom', 'matches', 'last', 'next', 'between', 'before', 'after', 'match_ranges', 'less_than', 'greater_than' |
value | The default filter value | String, Number, Boolean, or a List of these |
modifier | Time unit for date-based operators (e.g. 'last', 'next') | 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute' |
options | Extra behavior for specific operators. See options | Object |
options
| Parameter | Description | Accepted values |
|---|---|---|
include_current_period | For date operators like 'last'/'next': whether to include the current, still-in-progress period | Boolean |
settings
| Parameter | Description | Accepted values |
|---|---|---|
input_type | How viewers select a value | 'single', 'multiple', 'nullable-single' |
hide_label | Hides the control's label | Boolean |
hide_controls | Hides the filter's input controls from viewers | Boolean |
enable_drillthrough | Whether this filter can be targeted by drill-through from other dashboards. Only available when type is 'field' | Boolean |
drillthrough | Advanced drill-through configuration. See Drillthrough. Only available when type is 'field' | Drillthrough object |
Drillthrough
| Parameter | Description | Accepted values |
|---|---|---|
enabled | Whether advanced drill-through configuration is active | Boolean |
sources | Which source dashboards can drill through to this filter | List of AutoDrillthroughSource or CustomDrillthroughSource |
AutoDrillthroughSource automatically links all dashboards sharing the same dataset, except any listed in excluded_sources. See Advanced Drill-through configurations.
| Parameter | Description | Accepted values |
|---|---|---|
excluded_sources | Dashboards to exclude from auto-linking | List of dashboard names |
CustomDrillthroughSource links only the dashboards you explicitly list, instead of auto-linking by dataset. See Advanced Drill-through configurations.
| Parameter | Description | Accepted values |
|---|---|---|
sources | Dashboards to link for drill-through | List of dashboard names |
Examples
Date range filter with default
block date_filter: FilterBlock {
label: 'Order Date'
type: 'field'
source: FieldFilterSource {
dataset: ecommerce
field: r(orders.created_at)
}
default {
operator: 'matches'
value: 'last 30 days'
}
}
Categorical filter with multi-value default
block status_filter: FilterBlock {
label: 'Order Status'
type: 'field'
source: FieldFilterSource {
dataset: ecommerce
field: r(orders.status)
}
default {
operator: 'is'
value: ['active', 'pending']
}
}
Filter with user attribute default
block region_filter: FilterBlock {
label: 'Region'
type: 'field'
source: FieldFilterSource {
dataset: ecommerce
field: r(orders.region)
}
default {
operator: 'matches_user_attribute'
value: 'region'
}
}
Date filter with relative period and current period included
block f_text: FilterBlock {
label: 'Text'
type: 'date'
default {
operator: 'last'
value: '1'
modifier: 'month'
options {
include_current_period: true
}
}
}
Single-select filter with drillthrough
block f_users_role: FilterBlock {
label: 'Users Role'
type: 'field'
source: FieldFilterSource {
dataset: users
field: r(public_users.name)
}
default {
operator: 'is'
value: 'Admin'
}
settings {
input_type: 'single'
drillthrough: Drillthrough {
enabled: true
sources: [
AutoDrillthroughSource {
excluded_sources: [
'adventure_works_big'
]
}
]
}
}
}
Single-select filter with custom drillthrough sources
block f_users_role: FilterBlock {
label: 'Users Role'
type: 'field'
source: FieldFilterSource {
dataset: users
field: r(public_users.name)
}
default {
operator: 'is'
value: 'Admin'
}
settings {
input_type: 'single'
drillthrough: Drillthrough {
enabled: true
sources: [
CustomDrillthroughSource {
sources: [
'adventure_works_big',
'ecommerce_dashboard_test_ai'
]
}
]
}
}
}
See also
- AML Dashboard: full dashboard syntax
- AML Dashboard Interactions: interaction types reference
- Parameter Fields: bind filters to model param fields