# Substract in an order

**URL:** <https://discourse.nodered.org/t/substract-in-an-order/61176>\
**Category:** General\
**Tags:** function-node\
**Created:** [12 April 2022 12:30 UTC](https://discourse.nodered.org/t/substract-in-an-order/61176 "2022-04-12T12:30:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubenbraekman](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rubenbraekman/32/58663_2.png) [@rubenbraekman](https://discourse.nodered.org/u/rubenbraekman)\
**Post date:** [12 April 2022 12:30 UTC](https://discourse.nodered.org/t/substract-in-an-order/61176/1 "2022-04-12T12:30:56Z")

</div>

Hello, I'm now trying to substract 2 numbers but they need to be in a specific order, it always has to be PV\_DAK - PV\_SMA...

Any idea how to do this, when I copy the path to the numbers with said topics it just says "payload".

Thanks

 ![Knipsel](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/a/aa5f49d38e18bf0114c4f095b9c1e41b828989d9.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [12 April 2022 13:02 UTC](https://discourse.nodered.org/t/substract-in-an-order/61176/2 "2022-04-12T13:02:03Z")

</div>

You would need to join the two incoming messages.  
e.g.

```auto
[{"id":"b13ba1cb.18b6d8","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"PV_DAK","payload":"9999","payloadType":"num","x":400,"y":640,"wires":[["291f29ce.68968e"]]},{"id":"291f29ce.68968e","type":"join","z":"bf9e1e33.030598","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":580,"y":680,"wires":[["c386f74c.b4802"]]},{"id":"75a43cf6.270d74","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"PV_SMA","payload":"999","payloadType":"num","x":410,"y":720,"wires":[["291f29ce.68968e"]]},{"id":"c386f74c.b4802","type":"function","z":"bf9e1e33.030598","name":"","func":"msg.payload = msg.payload.PV_DAK - msg.payload.PV_SMA\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":680,"wires":[["da619082.64d898"]]},{"id":"da619082.64d898","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":960,"y":680,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![rubenbraekman](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rubenbraekman/32/58663_2.png) [@rubenbraekman](https://discourse.nodered.org/u/rubenbraekman)\
**Post date:** [12 April 2022 13:16 UTC](https://discourse.nodered.org/t/substract-in-an-order/61176/3 "2022-04-12T13:16:55Z")

</div>

Ok that works thank you, is there a way to give the output the topic PV\_ESS? Now the topic is just a random one from the inputs.  
Thanks

 ![Knipsel](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3e5adfeebdc9aa83c2679fe3575a1c7cfb057b65.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [12 April 2022 13:20 UTC](https://discourse.nodered.org/t/substract-in-an-order/61176/4 "2022-04-12T13:20:13Z")

</div>

yes add  
`msg.topic = "PV_ESS";`

---

<div class="post-metadata">

**Author:** ![rubenbraekman](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rubenbraekman/32/58663_2.png) [@rubenbraekman](https://discourse.nodered.org/u/rubenbraekman)\
**Post date:** [12 April 2022 13:26 UTC](https://discourse.nodered.org/t/substract-in-an-order/61176/5 "2022-04-12T13:26:30Z")

</div>

Ah yes thanks.

---

<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:** [26 April 2022 13:26 UTC](https://discourse.nodered.org/t/substract-in-an-order/61176/6 "2022-04-26T13:26:47Z")

</div>

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