# Is it possible to computation in node change?

**URL:** <https://discourse.nodered.org/t/is-it-possible-to-computation-in-node-change/33599>\
**Category:** General\
**Created:** [1 October 2020 02:47 UTC](https://discourse.nodered.org/t/is-it-possible-to-computation-in-node-change/33599 "2020-10-01T02:47:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [1 October 2020 02:47 UTC](https://discourse.nodered.org/t/is-it-possible-to-computation-in-node-change/33599/1 "2020-10-01T02:47:20Z")

</div>

I want to get the **length of the array + 1** , and set the value of the `node` change.  
I have tried 2 ways as below but don't work.

If possible, please tell me. Thanks!

 ![mode-change-3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/d/dd911980a39fd5aa01333d2898589327fcf3ccfc.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:** [1 October 2020 06:47 UTC](https://discourse.nodered.org/t/is-it-possible-to-computation-in-node-change/33599/2 "2020-10-01T06:47:33Z")

</div>

Yes using a JSONata expression

```auto
[{"id":"9f82063c.c6daf","type":"change","z":"4484ee28.caa3c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$count(msg.payload) + 1","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":460,"wires":[["269a25ff.79887a"]]}]

```

`$count(array) + 1`

> **[Array Functions · JSONata](https://docs.jsonata.org/array-functions)**
>
> \## \`$count()\`

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [1 October 2020 07:07 UTC](https://discourse.nodered.org/t/is-it-possible-to-computation-in-node-change/33599/3 "2020-10-01T07:07:59Z")

</div>

Great!!!  
Thank you very much for the support and reference link 🤗

---

<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:** [15 October 2020 07:08 UTC](https://discourse.nodered.org/t/is-it-possible-to-computation-in-node-change/33599/4 "2020-10-15T07:08:12Z")

</div>

Closed on 15 October 2020 07:08 UTC

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