Separate time reference for queries in the same dashboard

I am running Grafana v9.5.2 on a linux based operating system (Home Assistant). My data is coming from an InfluxDB installation.

I have a plot of temperature sensor data and I want to show a gauge on the same dashboard that gives me the maximum temperature for the past 24 hours.

The query I have setup for the gauge is:

SELECT max("value") FROM "autogen"."°F" WHERE ("entity_id"::tag = 'calibrated_kitchen_freezer_temperature') AND time >= 1687620683026ms and time <= 1687623965379ms GROUP BY time(24h) fill(null)

I set the relative time in the query options to “24h”.

When the dashboard time picker is set for “Last 24 hours”, the gauge show the right number with “Last 24h shown at the top” This is actually what I want to happen. However, when I zoom in on the graph, the gauge shows the maximum value for the time range selected. I do not want this, I want the gauge to remain displaying the 24 hour maximum temperature. When I go back to the time picker and select “Last 24h” again, I get the data back that I want.

I have looked at several forum posts about how to have a query with a different time range on the same dashboard and that is why I have the the relative time field to 24h. Either this is not working, or I do not understand very well how Grafana is supposed to work (which, in fact, may be the case).

Any help would be greatly appreciated.

You do not understand very well how Grafana is supposed to work. That relative time overrides only relative dashboards time range. But you will switch to absolute dashboard time range, when you zoom in on the graph.

Try to play with time range on the query level, e. g. time>=now() - 24h.