# How to hold last greater value until next value?

**URL:** <https://discourse.nodered.org/t/how-to-hold-last-greater-value-until-next-value/29989>\
**Category:** General\
**Created:** [13 July 2020 10:33 UTC](https://discourse.nodered.org/t/how-to-hold-last-greater-value-until-next-value/29989 "2020-07-13T10:33:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![muharremsari](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muharremsari/32/7996_2.png) [@muharremsari](https://discourse.nodered.org/u/muharremsari)\
**Post date:** [13 July 2020 10:33 UTC](https://discourse.nodered.org/t/how-to-hold-last-greater-value-until-next-value/29989/1 "2020-07-13T10:33:21Z")

</div>

I get values pyrometer from OPCDA server. This pyrometer measures the hot bar. The bar has to measure after entering the angle of view, then the bar moves, there is the outward viewing angle. The output is zero. How to keep great value until next bar?

---

<div class="post-metadata">

**Author:** ![xury](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/xury/32/25637_2.png) [@xury](https://discourse.nodered.org/u/xury)\
**Post date:** [13 July 2020 10:58 UTC](https://discourse.nodered.org/t/how-to-hold-last-greater-value-until-next-value/29989/2 "2020-07-13T10:58:52Z")

</div>

You can use context.set and context.get to compare values

---

<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:** [13 July 2020 11:24 UTC](https://discourse.nodered.org/t/how-to-hold-last-greater-value-until-next-value/29989/3 "2020-07-13T11:24:43Z")

</div>

Use a join node set to produce an array after 2 values.  
Try this flow to see the principle.

```auto
[{"id":"46eb32e6.39048c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"5ee5f03f.b624","type":"join","z":"46eb32e6.39048c","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":320,"y":80,"wires":[["74c796a9.0543c8"]]},{"id":"70b0c453.c3541c","type":"inject","z":"46eb32e6.39048c","name":"","topic":"","payload":"500","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":60,"wires":[["5ee5f03f.b624"]]},{"id":"d3006bfa.d790d8","type":"inject","z":"46eb32e6.39048c","name":"","topic":"","payload":"600","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["5ee5f03f.b624"]]},{"id":"74c796a9.0543c8","type":"debug","z":"46eb32e6.39048c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":600,"y":100,"wires":[]}]

```

---

<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:** [13 July 2020 11:26 UTC](https://discourse.nodered.org/t/how-to-hold-last-greater-value-until-next-value/29989/4 "2020-07-13T11:26:15Z")

</div>

I am not sure exactly what you want, but if you want to keep track of a maximum value then [the smooth node](https://flows.nodered.org/node/node-red-node-smooth) can do that I believe. However it may be that I don't understand the problem fully.

---

<div class="post-metadata">

**Author:** ![muharremsari](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muharremsari/32/7996_2.png) [@muharremsari](https://discourse.nodered.org/u/muharremsari)\
**Post date:** [13 July 2020 11:52 UTC](https://discourse.nodered.org/t/how-to-hold-last-greater-value-until-next-value/29989/5 "2020-07-13T11:52:52Z")

</div>

I appoligies.

It's a one float input. It's change between 0...1000 celcius degree. I would see pickup value in GUI until the next bar.

Best regards

---

<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:** [13 July 2020 12:27 UTC](https://discourse.nodered.org/t/how-to-hold-last-greater-value-until-next-value/29989/6 "2020-07-13T12:27:53Z")

</div>

Have a look at the smooth node as I suggested. See if that does it for you.

---

<div class="post-metadata">

**Author:** ![muharremsari](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muharremsari/32/7996_2.png) [@muharremsari](https://discourse.nodered.org/u/muharremsari)\
**Post date:** [13 July 2020 17:02 UTC](https://discourse.nodered.org/t/how-to-hold-last-greater-value-until-next-value/29989/7 "2020-07-13T17:02:09Z")

</div>

Almost default setting solved my problem. Thnks.

---

<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:** [27 July 2020 17:02 UTC](https://discourse.nodered.org/t/how-to-hold-last-greater-value-until-next-value/29989/8 "2020-07-27T17:02:22Z")

</div>

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