Multiple Time Range in dashboard - Specific day in previous week

Hello all,

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.

Is there a way to match “previous Monday” ?

Thank you

Hi, @amprantino!

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.

Best regards,
Lukas

Hello,

Inline to what was asked in this, do you think what asked in this feasible?

In the meantime I found a similar solution:

Select time: Today
In the graphs Edit > Time Range > Add time shift: 2d/d or 3d/d etc …

Then by selecting Monday (using customer range) I always have the requested day in the graphs.

I am using Grafana v5 and the "now/w-1w+1d " or "now/w-1w+2d " is not accepted :frowning:

@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.

are you trying to achieve something like this…?
image
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)

if yes, reply to me
if no, ignore me

by the way this is 2 years ago topic :joy:

1 Like

@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.

1 Like

Hey mate :slight_smile:
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? :slight_smile: