Filter Expressions
Filters are optional features that can be used to narrow the set of data from which a metric is computed. With logical expressions, you can also combine two or more filters within a single metric definition.
This sections describes MAQL functions that you can use for filtering your computations:
The basic syntax for filters uses following keywords:
SELECT ... WHERE ...
SELECT ... WHERE ... LIKE ...
SELECT ... HAVING ...
SELECT ... WHERE TOP(...) OF ...
Note
Values must be wrapped in double quotation marks ""
. For example:
SELECT {metric/revenue} WHERE {label/date.year} BETWEEN "2020" AND "2022"
You can use Logical Operators to combine filters.
Overriding Visualization filters with BY Keyword
At times, it may be useful to define a metric in a way that determines how the metric will be affected by contextual filters in visualizations or dashboards. This is where MAQL’s BY keywords for overriding visualization filters and Overriding Parent Filters come into play.