I want to create graphs in a dashboard and override the time range for the graphs.
Is there a way to match “previous Monday” or "previous Thursday " in the override section?
Its like “last calendar Monday” without respect for the current time of day.
For example, last Monday could be:
Override relative time “1d”
Add time shift “7d”
but the dashboard should always run on Monday. Additionally, the time doesn’t fit from 00:00 to 23:59 but is shifted according to current time.
There’s no option to select “previous Monday” in the time picker, but you can select “custom time range” and type a query like:
now/w+1d
and that’s going to select you Monday of the current week. For Monday of the previous week, use:
now/w-1w+1d
You can also deal with it on the panel level. When you set up a graph, you can add the time region (available under visualization -> thresholds & time regions), but it includes a timezone offset. As long as your datasource supports SQL, you can write an appropriate query to cast dates and then group your data by these dates appropriately.
e.g. with postgres:
SELECT current_date - cast(extract(dow from current_date) as int) + 1;
to get the datetime object representing the very beginning of Monday.
@lukaszsiatka@amprantino@turpedo Hello all, I have a similar kind of problem.
I want the change time ranges of the data at the dashboard level using query grafana(using variable). I tried using this query but it doesnt funtion as expected ( {"find": “terms”, “field”: “qrCodeSensor.keyword”, “query”: “importTime:now-1y to now”}).
Is it possible to do something like this? If Yes, then what would be the example query.
legend:
Call Count → call count based on selected time range (2021-01-01 to 2021-06-01)
Last Call Count → call count based on Last Year’s selected time range (2020-01-01 to 2020-06-01)
@bferdinandes Thank you for your reply.
Yes I am looking for something similar. I want do pass a query in Variables to change the time-range of the data in comeplete dashboard. I also tried couple of queries for the same, but nfortunately doesnt function.
Yes, this topic is very old, but found it on website and thought of giving a try.
Hey mate
Could you elaborate a bit more on this? I’m trying to show 2 different data lines in the Graph.
One for 2021 and one for 2020. How did you do this?