Hi just switched from Metabase to Grafana and i have a problem with my Time Series graph. With the following psql query:
SELECT
service.name AS package,
COUNT(*) AS service_on,
DATE_TRUNC(‘${time_variable}’, account.created_shot) AS time
FROM
account
LEFT JOIN
customer c ON c.id_account = account.id
RIGHT JOIN
property p ON p.id_customer = c.id
RIGHT JOIN
service ON service.id_property = p.id
WHERE
service.category = ‘test’
AND service.name IN ($pacchettotest)
– AND account.created_shot BETWEEN ‘2023-11-18’ AND ‘2023-11-21’
GROUP BY
service.name,
DATE_TRUNC(‘${time_variable}’, account.created_shot)
ORDER BY
time, service.name;
I obtain this graph if i select the “day” value of the variable ${time_variable}
But if i switch to “month” the graph aggregates each day of the month into the first resulting in wrong data
What i want to achieve is to have on each time occurrence ( day,week,month,year ) to show only the value of the first day of each time range.
It’s probably an issue with the DATE_TRUNC but if you guys have any solution i would be very happy.
Have a nice day