Function node with multiple calculations

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?

it's possible

[{"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

Thanks a lot👍🏻

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