Postgres Source - No value for count query equal to 0

Hi,

I want to have a Graph panel in Series mode to show the number of tasks completed and not completed.

Here’s my query:

SELECT
  $__timeGroup(time_col,'1m') as time,
  count(col_to_count)
FROM
  my_table
WHERE
  col_status= 'N' and $__timeFilter(time_col)
GROUP BY time

When the count is equal to 0, nothing is shown in the graph, even if I put the display null value to 0.
For the query with the ‘Y’ value (Completed tasks), it works.

How can I make it work? (I’m using Grafana 4.6.3)

Thanks,

You need to return data for every interval of your time group to get proper counts.

The easiest way to achieve that is joining against a generate_series query that returns a value for every time group.

You need something similar to https://github.com/grafana/grafana/issues/10073

There is a pull request to add this functionality directly to grafana but it has not been merged yet: https://github.com/grafana/grafana/pull/10138

Ok, I understand the issue.

I will wait the fix :wink: