# Sum up values from different text nodes

**URL:** <https://discourse.nodered.org/t/sum-up-values-from-different-text-nodes/55513>\
**Category:** General\
**Created:** [21 December 2021 08:58 UTC](https://discourse.nodered.org/t/sum-up-values-from-different-text-nodes/55513 "2021-12-21T08:58:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MR76](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@MR76](https://discourse.nodered.org/u/MR76)\
**Post date:** [21 December 2021 08:58 UTC](https://discourse.nodered.org/t/sum-up-values-from-different-text-nodes/55513/1 "2021-12-21T08:58:26Z")

</div>

Hey guys,  
I have 3 text nodes that have certain values written to them once a day. I now want to sum them up once a day and have them in another text node. I would also like to save the values until they are overwritten so they don't disappear after rebooting node red.

What would be the best way to do that? It seems like I cant use the values from the text nodes, so I guess I have to store them in some other node.

Best regards

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [21 December 2021 09:15 UTC](https://discourse.nodered.org/t/sum-up-values-from-different-text-nodes/55513/2 "2021-12-21T09:15:08Z")

</div>

I'm guessing all these are numbers.

Get the `join` node and set it to manual and set the count to `3`.

Output it as either an `object` or `array`.

Send that into a `function` node and parse the message and add the three values.

If you need more help, I can offer some examples.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [21 December 2021 09:28 UTC](https://discourse.nodered.org/t/sum-up-values-from-different-text-nodes/55513/3 "2021-12-21T09:28:46Z")

</div>

Here's an example flow.

```auto
[{"id":"e956d25316d0cce4","type":"join","z":"65c9b63cb09879a0","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":2100,"y":150,"wires":[["0199930b2b36b3c9"]]},{"id":"ac2c39148fb1e8e1","type":"inject","z":"65c9b63cb09879a0","name":"Reading 1","props":[{"p":"payload"},{"p":"topic","v":"","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"18","payloadType":"num","x":1950,"y":100,"wires":[["e956d25316d0cce4"]]},{"id":"9dee30a5a66c31ff","type":"inject","z":"65c9b63cb09879a0","name":"Reading 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"3","payloadType":"num","x":1950,"y":150,"wires":[["e956d25316d0cce4"]]},{"id":"9582d0acc2a9fa28","type":"inject","z":"65c9b63cb09879a0","name":"Reading 3","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"22","payloadType":"num","x":1950,"y":200,"wires":[["e956d25316d0cce4"]]},{"id":"0199930b2b36b3c9","type":"function","z":"65c9b63cb09879a0","name":"","func":"let a = msg.payload[0];\nlet b = msg.payload[1];\nlet c = msg.payload[2];\n\nlet total = a + b + c;\n\nmsg.payload = total;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2110,"y":190,"wires":[["9433cf93f867b403"]]},{"id":"9433cf93f867b403","type":"debug","z":"65c9b63cb09879a0","name":"Total","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2250,"y":190,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![MR76](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@MR76](https://discourse.nodered.org/u/MR76)\
**Post date:** [21 December 2021 10:00 UTC](https://discourse.nodered.org/t/sum-up-values-from-different-text-nodes/55513/4 "2021-12-21T10:00:31Z")

</div>

That works perfectly, thank you. I was having problems because for every text node I get a stream of msg. Using a throttle node solved that problem and I can use your solution.

---

<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 January 2022 10:00 UTC](https://discourse.nodered.org/t/sum-up-values-from-different-text-nodes/55513/5 "2022-01-04T10:00:51Z")

</div>

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