# Aggregate values to show "per time period"?

**URL:** <https://discourse.nodered.org/t/aggregate-values-to-show-per-time-period/734>\
**Category:** Dashboard\
**Created:** [11 June 2018 03:41 UTC](https://discourse.nodered.org/t/aggregate-values-to-show-per-time-period/734 "2018-06-11T03:41:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stwissel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stwissel/32/126_2.png) [@Stwissel](https://discourse.nodered.org/u/Stwissel)\
**Post date:** [11 June 2018 03:41 UTC](https://discourse.nodered.org/t/aggregate-values-to-show-per-time-period/734/1 "2018-06-11T03:41:37Z")

</div>

I have an eventsource posting values to NodeRED. I want to show some metrics in a dashboard:

- Events per minute for the last hour
- Events per hour for the last day
- Average value (each event comes with a measurement) per minute/hour

What’s a good way to aggregate? Would I use the context/flow/global object for that or something else?

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [11 June 2018 08:48 UTC](https://discourse.nodered.org/t/aggregate-values-to-show-per-time-period/734/2 "2018-06-11T08:48:18Z")

</div>

How about saving them to a database and aggregate from the database?

---

<div class="post-metadata">

**Author:** ![Stwissel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stwissel/32/126_2.png) [@Stwissel](https://discourse.nodered.org/u/Stwissel)\
**Post date:** [11 June 2018 09:21 UTC](https://discourse.nodered.org/t/aggregate-values-to-show-per-time-period/734/3 "2018-06-11T09:21:48Z")

</div>

Thx for the reply. Appreciate the time taken.  
Database is the plan B. Though for just a few values (60 & 24) in memory would do (and would be fast).  
Also found this: [https://flows.nodered.org/node/node-red-contrib-aggregator](https://flows.nodered.org/node/node-red-contrib-aggregator)  
Seem to do the trick

---

<div class="post-metadata">

**Author:** ![davidcgu](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@davidcgu](https://discourse.nodered.org/u/davidcgu)\
**Post date:** [11 June 2018 17:27 UTC](https://discourse.nodered.org/t/aggregate-values-to-show-per-time-period/734/4 "2018-06-11T17:27:33Z")

</div>

This ode you pointed seems to do something very similar to the standard palette smooth node, I don’t know what is the difference.

If you wanted to make something really easy you can do it with a simple counter and reset every hour or at a specific time, (maybe having various running) however this will give you the messages since a specific time, for instance since 00:00 or since 13:00 or whatever, not exactly latest 60 minutes.

Regards

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)\
**Post date:** [15 October 2018 08:36 UTC](https://discourse.nodered.org/t/aggregate-values-to-show-per-time-period/734/5 "2018-10-15T08:36:49Z")

</div>

FYI - I have raised following feature request : [https://github.com/jaggr2/node-red-contrib-aggregator/issues/10](https://github.com/jaggr2/node-red-contrib-aggregator/issues/10)  
for [node-red-contrib-aggregator](https://flows.nodered.org/node/node-red-contrib-aggregator)

Once implemented, this should give an even more real time view of the running average or running total over a configurable period.

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)\
**Post date:** [15 October 2018 09:57 UTC](https://discourse.nodered.org/t/aggregate-values-to-show-per-time-period/734/6 "2018-10-15T09:57:41Z")

</div>

In case the messages are arriving at fixed rate (e.g. once every 10 seconds) then [node-red-node-smooth](https://github.com/node-red/node-red-nodes/tree/master/function/smooth) can be used.
