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

**URL:** https://discourse.nodered.org/t/get-mean-value-from-influxdb-with-node-red-contrib-influxdb/67911
**Category:** General
**Created:** [19 September 2022 08:57 UTC](https://discourse.nodered.org/t/get-mean-value-from-influxdb-with-node-red-contrib-influxdb/67911 "2022-09-19T08:57:38Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Falfango](https://avatars.discourse-cdn.com/v4/letter/f/5e9695/32.png) [@Falfango](https://discourse.nodered.org/u/Falfango)
#### Post date: [19 September 2022 08:57 UTC](https://discourse.nodered.org/t/get-mean-value-from-influxdb-with-node-red-contrib-influxdb/67911/1 "2022-09-19T08:57:38Z")

</div>

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

A normal query with no GROUP BY works fine.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/2225816ad5ed1a6abc5fcc93e3896bda8ce9c03d.png)

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/3/73166bd521d155ab54f968ea7e8fe13b6cde4d11.png)

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?

---

<div class="post-metadata">

### Author: ![Falfango](https://avatars.discourse-cdn.com/v4/letter/f/5e9695/32.png) [@Falfango](https://discourse.nodered.org/u/Falfango)
#### Post date: [19 September 2022 09:04 UTC](https://discourse.nodered.org/t/get-mean-value-from-influxdb-with-node-red-contrib-influxdb/67911/2 "2022-09-19T09:04:47Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0dc2d5e1fd9348b617cafe3bb44e01be82cb8d7d.png)

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

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [19 September 2022 11:21 UTC](https://discourse.nodered.org/t/get-mean-value-from-influxdb-with-node-red-contrib-influxdb/67911/3 "2022-09-19T11:21:38Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [19 September 2022 13:05 UTC](https://discourse.nodered.org/t/get-mean-value-from-influxdb-with-node-red-contrib-influxdb/67911/4 "2022-09-19T13:05:11Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Falfango](https://avatars.discourse-cdn.com/v4/letter/f/5e9695/32.png) [@Falfango](https://discourse.nodered.org/u/Falfango)
#### Post date: [20 September 2022 05:02 UTC](https://discourse.nodered.org/t/get-mean-value-from-influxdb-with-node-red-contrib-influxdb/67911/5 "2022-09-20T05:02:11Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [20 September 2022 07:40 UTC](https://discourse.nodered.org/t/get-mean-value-from-influxdb-with-node-red-contrib-influxdb/67911/6 "2022-09-20T07:40:28Z")

</div>

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

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [20 September 2022 17:02 UTC](https://discourse.nodered.org/t/get-mean-value-from-influxdb-with-node-red-contrib-influxdb/67911/7 "2022-09-20T17:02:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [4 October 2022 17:02 UTC](https://discourse.nodered.org/t/get-mean-value-from-influxdb-with-node-red-contrib-influxdb/67911/8 "2022-10-04T17:02:45Z")

</div>

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