Dynamic Conditions in Visualization Block
A grasp of these concepts will help you understand this documentation better:
Introduction
With AQL Conditions, you can filter data in the visualization's filter section using expressions like:
buyers.buyer_gender == 'female' and sellers.seller_gender == 'female'
Dynamic Conditions take this a step further by parameterizing those values so users can control them via dashboard filters:
buyers.buyer_gender == {user_input} and sellers.seller_gender == {user_input}
This allows you to build interactive dashboards where filters apply to all metrics in the explore, without hardcoding values.
Use Case: Filter Multiple Models with the Same Condition
A common scenario is filtering data from multiple models using a single user-controlled parameter. For example, filtering both buyers and sellers by the same gender value.
Pre-requisite: This example assumes you have an ecom_transactions dataset with the following structure:
Dataset ecom_transactions {
...
models: [
buyers,
sellers,
transactions_buyers_sellers
]
relationships: [
relationship(transactions_buyers_sellers.buyer_id > buyers.buyer_id, true),
relationship(transactions_buyers_sellers.seller_id > sellers.seller_id, true)
]
}
Both buyers and sellers models have a gender dimension (e.g., buyer_gender and seller_gender).
Step 1: Create a Parameter Model
Model param_model {
type: 'query'
label: 'Param Model'
data_source_name: 'your_datasource'
query: @sql select 1 ;;
param gender_param {
label: 'Gender'
type: 'text'
}
}
Step 2: Add the Parameter Model to Your Dataset
Dataset ecom_transactions {
...
models: [buyers, sellers, transactions_buyers_sellers, param_model]
relationships: [
relationship(transactions_buyers_sellers.buyer_id > buyers.buyer_id, true),
relationship(transactions_buyers_sellers.seller_id > sellers.seller_id, true)
]
}