Hi team, I'm trying to calculate a 30 day runsum f...
# gd-beginners
m
Hi team, I'm trying to calculate a 30 day runsum for a fact that has gaps. I have the following metric, which I would expect to generate a continuous line. However, I still see gaps. What am I missing?
m
Hi Michael, thanks for sharing this over with us. 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(Cost(Fact), 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 and see if this helps in this case?
m
Copy code
SELECT RUNSUM(
    SELECT IFNULL({fact/ad_platform_metrics.cost}, 0) * 1
      for EACH {label/timestamp.day})
  ROWS BETWEEN 31 PRECEDING AND 1 PRECEDING
  WITH PF EXCEPT {label/timestamp.day}
This? This didn't work.
m
Thanks for checking that for me - Can you please confirm if you have also updated the config options - by checking the “Continuous line” checkbox in the Configuration > Canvas section settings. If checked, the line skips the missing value and connects the next available value.
m
That works, but... I was under the impression that shouldn't be necessary. What is the point of
for each
otherwise?
m
Perhaps you’re running into the case - as mentioned in our documentation here: https://www.gooddata.com/docs/cloud/create-metrics/maql/time/for-each/ Data Source Support for Dates: Some of the data sources may not fully support FOR EACH with date attributes: • Dremio, Drill, Redshift, and Synapse do not support FOR EACH for date attributes. • SQL Server 2022 (16.x), Azure SQL Database and Azure SQL Managed Instance support date attributes only from the compatibility level 160. Other data sources fully support FOR EACH for all attributes.
m
It doesn't mention Postgres. Is Postgres not supported?
j
Postgres is a supported database. Are you facing some error still?