Get Mean(value) from InfluxDB with node-red-contrib-influxdb

Hi!
I have a problem to get Mean() values with GROUP BY time().

A normal query with no GROUP BY works fine.

But when I add the Mean() and GROUP BY it returens only null-values

When I use the same query directly in InfluxDB it returns the mean-values.

Has anyone a idea, what I'm doing wrong or what I could do instead?

Sorry. As I read the post again, I saw, that the timepoints are very different. I expected that both queries will start with similiar time points. But they dont. Later datapoints show the mean values

I wonder, why both queries starts with so different time points with the same WHERE clause.

If I understand what you are asking correctly - surely you would expect any values in the first 10 minutes of your query not to return anything since there can be no mean until there are 10 minutes worth of data?

1 Like

If @TotallyInformation's suggestion is not it, then what local time was it when you ran the queries? What timezone are the machine running node red and (if different) the machine running the browser?

To be more clear. Without aggregate function, the result of the query starts with the first value in the database. Which results in "only" ~15 hours of data, even I asked for the last 24 hours (time>now()-1d). Thats ok, as that are all the data in the db at this time. But with aggregate function, the query results with 24 hours of data (null for the first 9 hours), with the same WHERE clause. I would have also expected, that only 15 hours of data would be in the result. As the db is growing, thats not really a problem, but I was irritated in the beginning, why I have "only" nulls in my results not looking on the timestamp. Thats why I started the thread, which was "resolved" with my first answer seeing the different timestamps.

I think you would have to ask on an influx forum if you wanted to know why it does that.

Have you tried the query in Grafana or via the InfluxDB command line to see if you get the same results?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.