# How to find max & min value from received values and shows it like this

**URL:** <https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038>\
**Category:** Dashboard\
**Created:** [14 July 2020 06:57 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038 "2020-07-14T06:57:41Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dev\_Soni](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@Dev\_Soni](https://discourse.nodered.org/u/Dev_Soni)\
**Post date:** [14 July 2020 06:57 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/1 "2020-07-14T06:57:42Z")

</div>

![IMG_20200714_122208](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/9/d99883fa5e1bc4e04c76f11620e058f6191350fa.jpeg)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 July 2020 07:30 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/2 "2020-07-14T07:30:47Z")

</div>

see this thread for an identical question... sounds like homework time again...

> [@Want to make a min/max text box on the dashboard for temp sensor output](https://discourse.nodered.org/t/want-to-make-a-min-max-text-box-on-the-dashboard-for-temp-sensor-output/30033/2):
>
> the node-red-node-smooth can show the most recent max or min for you.

---

<div class="post-metadata">

**Author:** ![Dev\_Soni](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@Dev\_Soni](https://discourse.nodered.org/u/Dev_Soni)\
**Post date:** [14 July 2020 09:15 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/3 "2020-07-14T09:15:37Z")

</div>

Thank You..😊😊

---

<div class="post-metadata">

**Author:** ![Dev\_Soni](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@Dev\_Soni](https://discourse.nodered.org/u/Dev_Soni)\
**Post date:** [14 July 2020 09:21 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/4 "2020-07-14T09:21:01Z")

</div>

Thank You..😊😊

---

<div class="post-metadata">

**Author:** ![Dev\_Soni](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@Dev\_Soni](https://discourse.nodered.org/u/Dev_Soni)\
**Post date:** [14 July 2020 17:50 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/5 "2020-07-14T17:50:43Z")

</div>

Plz explain more...I can't get which I want....

---

<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:** [14 July 2020 20:22 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/6 "2020-07-14T20:22:48Z")

</div>

Show us what you have tried so far and what there does not work.

---

<div class="post-metadata">

**Author:** ![Dev\_Soni](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@Dev\_Soni](https://discourse.nodered.org/u/Dev_Soni)\
**Post date:** [15 July 2020 03:47 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/7 "2020-07-15T03:47:58Z")

</div>

I have to show max and min values..at bottom of gauge ..like in pic..which i uploaded..

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 July 2020 04:52 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/8 "2020-07-15T04:52:55Z")

</div>

The question is: where do you get your data from. How do you want help if we dont know what you are working with.

---

<div class="post-metadata">

**Author:** ![Dev\_Soni](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@Dev\_Soni](https://discourse.nodered.org/u/Dev_Soni)\
**Post date:** [15 July 2020 05:33 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/9 "2020-07-15T05:33:36Z")

</div>

I made random data generating fuction and connected it with gauge on it I have to show current value & max value and min value...

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 July 2020 05:35 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/10 "2020-07-15T05:35:09Z")

</div>

Please post your flow.

---

<div class="post-metadata">

**Author:** ![Dev\_Soni](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@Dev\_Soni](https://discourse.nodered.org/u/Dev_Soni)\
**Post date:** [15 July 2020 06:50 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/11 "2020-07-15T06:50:26Z")

</div>

[HVAC&RemoteEnergyMonitoring\_DevSoni.json](https://discourse.nodered.org/uploads/short-url/lr7c8dVCZXCXnjCtBetjLg8KvsP.json) (10.8 KB)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 July 2020 07:37 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/12 "2020-07-15T07:37:59Z")

</div>

You could do it like this. Note that you cannot dynamically set the range values of the gauge, so i used to text fields.

You will have to set an initial minimum and maximum to compare against (see the function node).

```auto
[{"id":"1d161e35.b8c412","type":"ui_gauge","z":"532ca152.47d2e","name":"","group":"a0643bc4.6e36a","order":1,"width":"6","height":"6","gtype":"wave","title":"Current","label":"A","format":"{{value}}","min":0,"max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":300,"y":432,"wires":[]},{"id":"7fe2344e.83684c","type":"ui_chart","z":"532ca152.47d2e","name":"","group":"a0643bc4.6e36a","order":4,"width":"6","height":"10","label":"Current","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"00","ymax":"50","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":300,"y":492,"wires":[[]]},{"id":"6fe4fb05.b6de34","type":"inject","z":"532ca152.47d2e","name":"","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":166,"y":336,"wires":[["673ed388.d4f7bc"]]},{"id":"673ed388.d4f7bc","type":"function","z":"532ca152.47d2e","name":"rnd","func":"msg.payload = Math.round(Math.random()*40);\nreturn msg;\n","outputs":1,"noerr":0,"x":314,"y":336,"wires":[["b5027d4.53d72"]]},{"id":"b5027d4.53d72","type":"mqtt out","z":"532ca152.47d2e","name":"pubcur","topic":"Plant1/cur","qos":"2","retain":"","broker":"425e991b.63e368","x":444,"y":336,"wires":[]},{"id":"34380b4b.8083dc","type":"mqtt in","z":"532ca152.47d2e","name":"subcur","topic":"Plant1/cur","qos":"2","datatype":"auto","broker":"425e991b.63e368","x":122,"y":456,"wires":[["1d161e35.b8c412","7fe2344e.83684c","7509e58e.22ac7c"]]},{"id":"d0f8b40b.3a728","type":"ui_text","z":"532ca152.47d2e","group":"a0643bc4.6e36a","order":2,"width":0,"height":0,"name":"min","label":"min","format":"{{msg.payload.min}}","layout":"row-spread","x":482,"y":528,"wires":[]},{"id":"ad2beaf5.6d646","type":"ui_text","z":"532ca152.47d2e","group":"a0643bc4.6e36a","order":3,"width":0,"height":0,"name":"","label":"max","format":"{{msg.payload.max}}","layout":"row-spread","x":482,"y":576,"wires":[]},{"id":"7509e58e.22ac7c","type":"function","z":"532ca152.47d2e","name":"","func":"m = parseFloat(msg.payload)\n\nmin = flow.get(\"min\") || 6 // minimum value \nmax = flow.get(\"max\") || 7 // maximum value \n\nif(m<min && m <=max){\n flow.set(\"min\",m)\n min = flow.get(\"min\")\n}\nif(m>max){\n \n flow.set(\"max\",m)\n max = flow.get(\"max\")\n \n}\n\n\nreturn {payload:{min:min,max:max}};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":552,"wires":[["d0f8b40b.3a728","ad2beaf5.6d646","cf55b950.b053c"]]},{"id":"cf55b950.b053c","type":"debug","z":"532ca152.47d2e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":502,"y":624,"wires":[]},{"id":"a0643bc4.6e36a","type":"ui_group","z":"","name":"Currrent(Ampere)","tab":"2590396a.bb5e46","order":5,"disp":true,"width":"6","collapse":false},{"id":"425e991b.63e368","type":"mqtt-broker","z":"","name":"","broker":"broker.hivemq.com","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"2590396a.bb5e46","type":"ui_tab","z":"","name":"Plant-1","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![Dev\_Soni](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@Dev\_Soni](https://discourse.nodered.org/u/Dev_Soni)\
**Post date:** [17 July 2020 14:47 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/13 "2020-07-17T14:47:40Z")

</div>

Perfect Brother.... 🥰

---

<div class="post-metadata">

**Author:** ![Dev\_Soni](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@Dev\_Soni](https://discourse.nodered.org/u/Dev_Soni)\
**Post date:** [17 July 2020 14:48 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/14 "2020-07-17T14:48:14Z")

</div>

Thanx a lot....

---

<div class="post-metadata">

**Author:** ![Joaovitor](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@Joaovitor](https://discourse.nodered.org/u/Joaovitor)\
**Post date:** [17 July 2020 15:38 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/15 "2020-07-17T15:38:21Z")

</div>

I don't know if you've found what you're looking for. If it is useful, I already had the same question and developed the following flow to record these values.

See that the buttons are responsible for resetting the system, inserting very high reference values ​​in relation to the input values. In addition, there is a time stamp of the readings.

You have to adapt, but it may be useful.

`[{"id":"ef356694.2d2f48","type":"change","z":"cfbb6e4f.6526a","name":"","rules":[{"t":"set","p":"max","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":4160,"wires":[["60f61f3b.8c15a"]]},{"id":"55c269fe.b25fd8","type":"ui_button","z":"cfbb6e4f.6526a","name":"","group":"cf817aa5.c91f38","order":3,"width":8,"height":1,"passthru":true,"label":"Reset - max","tooltip":"","color":"","bgcolor":"","icon":"","payload":"-10000","payloadType":"num","topic":"","x":910,"y":4160,"wires":[["ef356694.2d2f48"]]},{"id":"1233d78.a7bba29","type":"ui_text","z":"cfbb6e4f.6526a","group":"cf817aa5.c91f38","order":1,"width":3,"height":1,"name":"value max","label":"","format":"{{msg.payload}}","layout":"row-left","x":1450,"y":4180,"wires":[]},{"id":"fca3d950.88ab78","type":"switch","z":"cfbb6e4f.6526a","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"max","vt":"flow"},{"t":"lt","v":"min","vt":"flow"}],"checkall":"true","repair":false,"outputs":2,"x":1010,"y":4200,"wires":[["ef356694.2d2f48"],["8edcf000.641ec"]]},{"id":"60f61f3b.8c15a","type":"function","z":"cfbb6e4f.6526a","name":"","func":"if(msg.payload == -10000)\n{\n msg.payload = \"-\"\n}else\n{\n msg.payload = msg.payload + \" cm \"\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1310,"y":4160,"wires":[["1233d78.a7bba29","7435ffd1.4cb91"]]},{"id":"7435ffd1.4cb91","type":"simpletime","z":"cfbb6e4f.6526a","name":" date / time ","x":1450,"y":4140,"wires":[["4d6502b4.006b3c"]]},{"id":"4d6502b4.006b3c","type":"function","z":"cfbb6e4f.6526a","name":" date / time composition","func":"var a = \"(\"+msg.mydom+\"/\"+msg.mymonthn+\"/\"+msg.myyear+ \" - \" +msg.mytimes+\")\";\nmsg.payload = a;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1650,"y":4140,"wires":[["3c40a80a.e452f8"]]},{"id":"3c40a80a.e452f8","type":"ui_text","z":"cfbb6e4f.6526a","group":"cf817aa5.c91f38","order":2,"width":5,"height":1,"name":"date / time","label":"","format":"{{msg.payload}}","layout":"row-left","x":1630,"y":4180,"wires":[]},{"id":"8edcf000.641ec","type":"change","z":"cfbb6e4f.6526a","name":"","rules":[{"t":"set","p":"min","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":4240,"wires":[["e41a3ac4.7ff478"]]},{"id":"8f49175.c82b3e8","type":"ui_button","z":"cfbb6e4f.6526a","name":"","group":"fb78e249.cda99","order":3,"width":8,"height":1,"passthru":true,"label":"Reset - min","tooltip":"","color":"","bgcolor":"","icon":"","payload":"10000","payloadType":"num","topic":"","x":910,"y":4240,"wires":[["8edcf000.641ec"]]},{"id":"e41a3ac4.7ff478","type":"function","z":"cfbb6e4f.6526a","name":"","func":"if(msg.payload == 10000)\n{\n msg.payload = \"-\"\n}else\n{\n msg.payload = msg.payload + \" cm \"\n}\nreturn msg;","outputs":1,"noerr":0,"x":1310,"y":4240,"wires":[["3e85ada5.985b02","8cc0b0ad.31d46"]]},{"id":"3e85ada5.985b02","type":"ui_text","z":"cfbb6e4f.6526a","group":"fb78e249.cda99","order":1,"width":3,"height":1,"name":"value min","label":"","format":"{{msg.payload}}","layout":"row-left","x":1440,"y":4260,"wires":[]},{"id":"8cc0b0ad.31d46","type":"simpletime","z":"cfbb6e4f.6526a","name":" date / time ","x":1450,"y":4220,"wires":[["e815eab4.b94788"]]},{"id":"e815eab4.b94788","type":"function","z":"cfbb6e4f.6526a","name":" date / time composition","func":"var a = \"(\"+msg.mydom+\"/\"+msg.mymonthn+\"/\"+msg.myyear+ \" - \" +msg.mytimes+\")\";\nmsg.payload = a;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1650,"y":4220,"wires":[["e69f6304.ad773"]]},{"id":"e69f6304.ad773","type":"ui_text","z":"cfbb6e4f.6526a","group":"fb78e249.cda99","order":2,"width":5,"height":1,"name":"date / time","label":"","format":"{{msg.payload}}","layout":"row-left","x":1630,"y":4260,"wires":[]},{"id":"3aa77469.214dcc","type":"function","z":"cfbb6e4f.6526a","name":" purchase value (sensor)","func":"\nmsg.payload = Number(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":830,"y":4200,"wires":[["fca3d950.88ab78"]]},{"id":"cf817aa5.c91f38","type":"ui_group","z":"","name":"Valor máximo ","tab":"afeb27be.73ba48","order":5,"disp":true,"width":"8","collapse":false},{"id":"fb78e249.cda99","type":"ui_group","z":"","name":"Valor mínimo","tab":"afeb27be.73ba48","order":6,"disp":true,"width":"8","collapse":false},{"id":"afeb27be.73ba48","type":"ui_tab","z":"","name":"HC-SR04 - Distância","icon":"settings_input_antenna","order":3,"disabled":false,"hidden":false}]`

---

<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:** [31 July 2020 15:38 UTC](https://discourse.nodered.org/t/how-to-find-max-min-value-from-received-values-and-shows-it-like-this/30038/16 "2020-07-31T15:38:26Z")

</div>

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