# Function node with multiple calculations

**URL:** https://discourse.nodered.org/t/function-node-with-multiple-calculations/68698
**Category:** General
**Created:** [7 October 2022 23:13 UTC](https://discourse.nodered.org/t/function-node-with-multiple-calculations/68698 "2022-10-07T23:13:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![PowerZone21](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/powerzone21/32/67873_2.png) [@PowerZone21](https://discourse.nodered.org/u/PowerZone21)
#### Post date: [7 October 2022 23:13 UTC](https://discourse.nodered.org/t/function-node-with-multiple-calculations/68698/1 "2022-10-07T23:13:59Z")

</div>

Hi Guys.

I have this function node: [{"id":"3d87b88c4f3623f6","type":"function","z":"1a975b2abb684217","name":"Calc spotprice","func":"var average = global.get('daily\_spotprice\_avg')\nvar spot = global.get('hourly\_spotprice')\n\nmsg.payload = (spot-(average\*2))\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":980,"y":1660,"wires":[["0dc235179a05b087"]]}]

Witch are working like it should.  
Is it possible to add more than one calculation that goes to more than one output?

Lets say, I want to have 4 calculations that goes to 4 outputs?

---

<div class="post-metadata">

### Author: ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)
#### Post date: [7 October 2022 23:43 UTC](https://discourse.nodered.org/t/function-node-with-multiple-calculations/68698/2 "2022-10-07T23:43:20Z")

</div>

it's possible

```auto
[{"id":"869e8694663d19b0","type":"function","z":"be783776ae679c4d","name":"output 4","func":"var Msg1;\nvar Msg2;\nvar Msg3;\nvar Msg4;\n\nlet MyVar = 1 + 1;\nMsg1 = {\n payload: MyVar\n}\nMsg2 = {\n payload: MyVar\n}\nMsg3 = {\n payload: MyVar\n}\nMsg4 = {\n payload: MyVar\n}\nreturn [Msg1,Msg2,Msg3,Msg4];","outputs":4,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":100,"wires":[[],[],[],[]]},{"id":"ed316a1a6641645c","type":"inject","z":"be783776ae679c4d","name":"3 sec","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":410,"y":100,"wires":[["869e8694663d19b0"]]}]

```

what are you trying to do?  
[edit] by the way your flow won't import

---

<div class="post-metadata">

### Author: ![PowerZone21](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/powerzone21/32/67873_2.png) [@PowerZone21](https://discourse.nodered.org/u/PowerZone21)
#### Post date: [8 October 2022 00:20 UTC](https://discourse.nodered.org/t/function-node-with-multiple-calculations/68698/3 "2022-10-08T00:20:21Z")

</div>

Thanks a lot👍🏻

---

<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: [7 December 2022 00:20 UTC](https://discourse.nodered.org/t/function-node-with-multiple-calculations/68698/4 "2022-12-07T00:20:44Z")

</div>

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