Hello, we’re having some sparse data based on dat...
# gooddata-platform
t
Hello, we’re having some sparse data based on dates, and wanted to display it as a timeseries. However, when using a bar chart or a line chart, the axis only shows the dates that actually have data. How can we also display the dates that do NOT have datapoints associated to them? It is a very common request, that we got multiple times by now, and we didn’t find a chart option to do that. Would that be doable with custom metrics or computed attributes?
m
Hi Tomas, the IFNULL statement allows you to predefine how the GoodData platform addresses any missing values that are returned by an expression. If a metric expression that is wrapped within an IFNULL statement ever returns a null value, the replacement number specified in the second parameter of the IFNULL function is inserted in place of the null value. More details on this can be found here: https://help.gooddata.com/doc/enterprise/en/dashboards-and-insights/maql-analytical-q[…]language/maql-expression-reference/logical-functions/ifnull/
t
OK, so if I have data for lets say “order count” for August 3rd, 10th, and 11th, and I wrap that in an IFNULL, I’ll see a chart spanning the whole august?
will try
Copy code
The IFNULL function does not populate rows of data when the row does not exist. Rather, it forces a value to appear when the value is blank.
I think this is a problem. I can’t populate the source data with 0 or NULL values, since we have it split by quite a few dimensions. Filling NULLs for all combinations of that is completely impossible
m
Although you will not have any data for the other dates, if you use the IFNULL function it will force the missing dates to be shown in your chart - Your metric would look something like:
Copy code
SELECT IFNULL(COUNT(Order), 0)
t
ok, lets try that
unfortunately that didn’t work
dates are only populated when there was a data point
I think a hacky trick would be to combine it with another data point that is always there, even though I have to look if that exists
m
Can you try the following to try and force the 0 to display - please try and update your metric to something like:
Copy code
SELECT IFNULL(COUNT(Order), 0)*1
In some cases, the *1 forces 0 to appear even when there is no data. can you please try and give this a go?
t
Interesting. Will try as well
That worked indeed! I guess that’s worth an update in the online articles! Thanks a lot, not only for helping me finding this, but also for the after-hours work time!
m
Thanks for letting me know that it worked and for your feedback - Have a great rest of the day 🙂