AML FilterBlock
FilterBlock adds a user-controlled filter to the dashboard. Viewers interact with it to narrow down the data shown in connected visualization blocks.
Syntax
block <name>: FilterBlock {
label: 'Filter Label'
type: 'field'
source: FieldFilterSource {
dataset: <dataset_name>
field: r(<model>.<field>)
}
default { // optional
operator: '...'
value: '...'
}
}
Parameters
| Parameter | Description |
|---|---|
label | Display name shown on the filter control. |
type | Filter type. Use 'field' to filter on a dataset field. |
source | A FieldFilterSource specifying which field to filter on. |
default | Optional default filter value applied when the dashboard loads. |
FieldFilterSource
FieldFilterSource points to the field the filter controls.
| 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 |
|---|---|
operator | How to apply the filter. Common values: 'is', 'matches', 'matches_user_attribute'. |
value | The default filter value. Can be a string, a list, or a relative date expression. |
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'
}
}
See also
- AML Dashboard: full dashboard syntax including interactions
- Parameter Fields: bind filters to model param fields