These cookies provide us with information on how our websites are being used, to help us improve the quality and relevance of content we place on them. Additionally, they also allow us to show you embedded videos and remember your preferences and actions, so that the websites do not bother you with the same request repeatedly (e.g. filling a form to download a PDF file and provide feedback about such actions to our affiliated entities).
You are viewing our older product's guide. Click here for the documentation of GoodData Cloud, our latest and most advanced product.
Filtering with the HAVING Clause
Using the HAVING filter enables you to apply filtration to a metric after all containing metrics and aggregation functions have been computed.
In MAQL, the WHERE clause is used to perform basic filtration on your data before it has been aggregated. In some cases, you may want to filter your metric data after it has been aggregated, so that you can make conditional evaluations based on the results of the computations within the metric.
HAVING clause filtration is applied after all other conditions of the metric have been resolved.
You cannot apply the HAVING keyword in a metric that contains a WHERE clause.
Syntax
If your metric contains multiple keywords, they must be listed in alphabetical order:
Restrictions
Suppose you have created a metric containing the following:
However, since there is no direct relationship between Quarter and Region or between Product and Region, the HAVING clause conditions are ignored.
However, if the HAVING clause included Quarter, Year, Product, or Product Category, then the filter would be applied.
A HAVING filter is only applied if the data model supports its evaluation.
Examples
The last MAQL statement above returns values for amount for the quarter before this one, displaying only results from 2014. No parent filters are applied.