Hello all, Quick question. I have a chart here tha...
# gd-beginners
d
Hello all, Quick question. I have a chart here that is showing incorrect numbers from the data available and it is due to a lack of "group by". So for example, I have data for the 3/17 dot you see in the picture provided on the messages chart. I have 10 records but should only see a 5 in the chart because I want to group by an id we have specified in our data. The MAQL I currently have is
SELECT IFNULL(COUNT({dataset/messages}),0) + SUM({fact/zero.zero}) BY {label/messages.thread_id}
. It would seem that "BY" would group these by that id but it is not doing so. Is there something I am doing incorrectly? Hopefully this is enough info to give good context.
m
Hello Drew, it seems that you should be applying some filtering instead of stablishing an aggregation floor with the “BY” keyword. Could you try specifying the id with the WHERE clause? You should also be able to apply the filtering directly to the insight or dashboard by dragging and dropping the corresponding attribute and selecting the ID in question. Please see: Add Filters to Dashboards
t
Hi Drew, can you elaborate a bit more about the desired state? • Would you like to see multiple lines, each for a different ID? • Or would you like to see one line, bet each ID should be counted only once per day? • Or would you like to filter out particular IDs?
d
@Tomas Muchka I would like to to see a single line but each id should be counted only once per day.
t
Could you try to use other variants of count as described here? I don't have a hands on experience with those, but it seems that the variant that utilizes the keyword USING could do the job in your case. https://www.gooddata.com/docs/cloud/create-metrics/maql/aggregation/count/#COUNT-SpecifyingCOUNTContextResolutionwithUSING
d
I will give it a try!
t
Or maybe just try to count the message_ids instead of all the dataset records. GoodData should do a unique count by default, but it needs to know the granularity where it should operate.
d
@Tomas Muchka counting by the message_ids worked and did the job! Thanks again.
🙌 2