-
What Grafana version and what operating system are you using?
Grafana version 8.1.1 -
What are you trying to achieve?
I want to write a query similar to this for the current month. This query I have written to get totals of last 30 days. But How can I write a query to get totals of current month, for an example totals from 2021-09-01 to 2021-09-21, from 2021-09-01 to 2021-09-22 likewise.
select $__timeFilter(TX_Date) as “time”,sum(Accepted_Count) as “Total” from transactions
where dept_id=1 and (TX_Date < CURDATE() and TX_Date >= DATE_SUB(CURDATE(),INTERVAL 30 DAY))
group by dept_id;
-
How are you trying to achieve it?
I write the query in this manner and change the time range to “This Month” from the drop down in upper right corner.
select $__timeFilter(TX_Date) as “time”,sum(Accepted_Count) as “Total” from transactions
where dept_id=1
group by dept_id;
-
What happened?
But when there is no value in database, it gives the totals for whole period. -
What did you expect to happen?
If there is no value for particular metrics in Data base, show the value 0. I set the calculation option as this.
-
Can you copy/paste the configuration(s) that you are having problems with?
-
Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
-
Did you follow any online instructions? If so, what is the URL?