InfluxDB query - maximum/minimum values are incorrect

Hi all,
I have an InfluxDB datasource with an increasing variable.
Then there are 2 queries:
SELECT (max("value") ) FROM "MWh" WHERE ("entity_id" = 'heater_meters_sou_energy1') AND $timeFilter GROUP BY time(1d,-1h)
and
SELECT (min("value")) FROM "MWh" WHERE ("entity_id" = 'heater_meters_sou_energy1') AND $timeFilter GROUP BY time(1d,-1h)

The time(1d,-1h) is because my timezone is CET.

I have no offset applied to the source data, but that should not be relevant when both queries have the same offset.

I expect that yesterdays maximum value equals today’s minimum value, but it doesn’t:
as can be seen in the datasource, on 23-03 the latest value is 17.5020 which correctly equals the ‘max’ value on the bar chart.
The first datapoint on 24-03 is created at 00:29 (17.5030), so before that time the value was still 17.5020, but the bar chart shows 17.5030 as the minimum value.

What am I doing wrong?
Thanks for any help!

I suppose this is more of an Influx question than a Grafana question. Either way, from what I can see the results you’re getting are correct. The issue I think is with your expectation (emphasis mine):

The first datapoint on 24-03 is created at 00:29 (17.5030), so before that time the value was still 17.5020

Indeed the first datapoint on 24-03 is 17.5030, so when you run an Influx query to select the minimum value from that day, this is what’s returned. The 17.5020 value is from the previous day, and therefore outside the 24-hour query window window, so it’s just not included in the Influx query.

The concept of a value existing continuously over time, and changing occasionally, doesn’t really hold. Influx simply has discrete timestamped datapoints, which can either be inside or outside your query window. Hopefully I’m making sense

If you do want the “minimum” of a day to actually be the previous day’s maximum, then I suppose you could run a query like

SELECT (max("value")) FROM "MWh" WHERE ("entity_id" = 'heater_meters_sou_energy1') AND $timeFilter GROUP BY time(1d,-25h)

(I’m somewhat speculating that the offset on GROUP BY time() works this way, but hopefully the idea holds)

Hi Svetb, thank you for your reply.

It makes complete sense, thanks for the clear answer and alternative. I will try some queries!