Display Max Value Over Selected Time Range

Hi everyone,

I am very new to InfluxDB and Grafana and I’ve been trying to follow online tutorials and figure out things to the best of my ability, but I’ve sort of hit a probably rather simple roadblock I’m unable to overcome… I’m using InfluxDB with Grafana in Home Assistant. I have two queries below, which are supposed to show the current and maximum value of the sensor “wind_speed”.

What I’m trying to do is have the first query show the current wind speed, regardless of the time frame selected (top right - currently last 24hr), because the current state shouldn’t be affected by the timeframe anyway. This works with the current parameters shown, but I have a feeling it’s only working because of luck, as the current field(value) is set to mean()…

Anyway, the problem I’m having is with the second query. I want the second query to show the max value of the sensor over the selected timeframe - in this case the past 24 hours. Unfortunately, it’s not doing that. As you can see, it’s showing 10 mph for both, when the maximum value is in fact 17 mph. I know that I can remove the time($_interval) parameter and it will show me the max value, but not over the selected timeframe, it shows the max value ever , which is not what I want.

I’m sure this is super simple, but I’m having trouble grasping why what I have wouldn’t work. Thanks in advance!

Hello @Kackerlacka,
Rather than group by 24 hours i would limit the time is greater than the last 24 hours.
My InfluxQL query would look something like this

SELECT mean("wind_spead") AS "avg" FROM "database"."windspeed" where "endity_id"=="wind_speed" and 
time > -24h fill(none)