Hey GoodData, I’m trying to create a headline (GD ...
# gd-beginners
m
Hey GoodData, I’m trying to create a headline (GD Cloud) and want to sum across my only attribute and average across the date range that is chosen. It seems that without creating a metric via MAQL, I can only either get the headline summed across my attribute and summed across the date range or averaged across my attribute and averaged across the date range. I have one data point per month, the attribute is stores and the metric is number of new customers. For any given date range, I want the total new customers across stores, but averaged across the specified date range. I assume I need to use MAQL to do this? How do I do this? Thanks! Further example: I may have 5000 total new customers (sum across stores) in Jan and 4000 total new customers in Feb. If my date range is Jan and Feb, the value I want to see is 4500.
j
Try something like
select avg(select sum({fact/new_customers}) by {attribute/date.day})
. It will calculate sum of new customers across stores (and other dimensions) by day and average across data points on time axis. It will be average of two values if you select two months because sum by day will return only two values because there is only one data point per month. You can use also
select avg(select sum({fact/new_customers}) by {attribute/date.month})
. It will calculate sum by month and then calculate average of the monthly values.
🙌 1
m
thanks!
j
Btw. sum by day will probably better work with date range filters. Sum by month can be filtered by range of years, quarters and months but not days or weeks.
👍 1
m
It works, tyvm!
j
Enjoy power of MAQL 🙂