Slackbot
04/29/2026, 1:50 AMkapa.ai
04/29/2026, 1:50 AMCASE WHEN on a fact (recency_days). To then get a distinct count of player_id per group, you'll need to combine CASE with COUNT â but there are some important constraints to be aware of. What's Supported In GoodData MAQL, COUNT already returns distinct values by default â there's no separate DISTINCT keyword needed. [COUNT]
The recommended pattern for using CASE inside an aggregation is to wrap the CASE inside a SUM container. However, for a distinct count per group, the typical approach is:
1. Define the recency group as an attribute in your data model (e.g., via a SQL Dataset that computes the bucket), then use COUNT({label/player_id}) sliced by that attribute in a visualization. [CASE statement]
2. Alternatively, use the CASE pattern inside SUM to assign a numeric value per row, but note that CASE does not work at the base data level â it evaluates on the aggregation dimension. This means you cannot directly do COUNT(DISTINCT player_id) WHERE CASE WHEN ... in a single MAQL metric. [CASE statement] Practical Recommendation The most robust approach given this limitation is to precompute the recency group as a column/attribute in your data source or via a SQL Dataset in GoodData. For example, add a recency_group column with values like "<30", "31-90", "91-365", "Year+" at the ETL/SQL level. Then in GoodData, you can simply use:
SELECT COUNT({label/player_id})
...sliced by the recency_group attribute in a table visualization, and GoodData will automatically return the distinct count of player_id per group.
This sidesteps the MAQL CASE limitation and is the recommended pattern for bucketing use cases in GoodData Cloud. [CASE statement]
> Note: If you need to keep the logic purely in MAQL, you would need to create separate metrics for each recency bucket (one per WHERE condition) and display them side by side, rather than dynamically grouping them in a single metric. đ 0 button đ 0 button âšī¸ Tip: Mention @kapa.ai in the thread for follow-ups.
đ Our Support team monitors all messages and will jump in if needed.