Skip to main content

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

ParameterDescription
labelDisplay name shown on the filter control.
typeFilter type. Use 'field' to filter on a dataset field.
sourceA FieldFilterSource specifying which field to filter on.
defaultOptional default filter value applied when the dashboard loads.

FieldFilterSource

FieldFilterSource points to the field the filter controls.

ParameterDescription
datasetThe dataset name.
fieldReference to the field using r(model.field) syntax.

default

The default block sets the initial filter state when the dashboard loads.

ParameterDescription
operatorHow to apply the filter. Common values: 'is', 'matches', 'matches_user_attribute'.
valueThe 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


Open Markdown
Let us know what you think about this document :)