Skip to main content
โ† Back to index page

โ›ณ AQL Condition: Apply Complex Filters to All Metrics at Once

Stop duplicating the same filter logic across every metric in your exploration. AQL Condition lets you define filtering criteria once and apply it to all your metrics automatically.

Why this feature?โ€‹

When building explorations, you often need to apply the same complex filter to multiple metrics. Previously, you had to add where() clauses to every single metric, leading to repetitive code and maintenance headaches. If you needed to change the filter logic, you'd have to update it in multiple places.

Now you can define your filtering logic once in the explore's filters block, and it automatically applies to all metrics.

How it worksโ€‹

AQL Condition uses the same expression syntax as the where() function's condition parameter, but you define it at the exploration level instead of repeating it for each metric.

Before vs Afterโ€‹

Before (Repetitive filtering)

explore {
dimensions {
// your_dimensions
}
measures {
orders: total_orders | where(users.gender == 'female' or countries.name == 'Vietnam'),
revenue: revenue | where(users.gender == 'female' or countries.name == 'Vietnam'),
users: total_users | where(users.gender == 'female' or countries.name == 'Vietnam')
}
filters {
// your_condition
}
}

After (Single filter definition)

explore {
dimensions {
// your_dimensions
}
measures {
orders: total_orders,
revenue: revenue,
users: total_users
}
filters {
users.gender == 'female' or countries.name == 'Vietnam'
}
}

This approach makes your code cleaner and easier to maintain, while ensuring consistent filtering across all metrics.

Learn moreโ€‹

See the full documentation: AQL Condition reference

For making conditions dynamic with dashboard filters, see: Dynamic Conditions