# Array changes after a time

**URL:** <https://discourse.nodered.org/t/array-changes-after-a-time/13414>\
**Category:** General\
**Created:** [17 July 2019 20:15 UTC](https://discourse.nodered.org/t/array-changes-after-a-time/13414 "2019-07-17T20:15:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![debouttek](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@debouttek](https://discourse.nodered.org/u/debouttek)\
**Post date:** [17 July 2019 20:15 UTC](https://discourse.nodered.org/t/array-changes-after-a-time/13414/1 "2019-07-17T20:15:15Z")

</div>

I'm reading a power consumption device with 2 clamps for solar production and my power consumption.  
I have good readings and the problem is a array problem. I would like to subtract my Consumption minus solar production.

I have made a join node that gives me an output with 2 arrays (screenshot)  
Then I used the node node-red-contrib-calc and there I made a subtraction.

My 2 arrays are called in debug node 0 and 1

So it needs to subtract ARRAY 0 from ARRAY 1 and here is the problem. Sometimes its ok and sometimes it switches ARRAY 1 first and then ARRAY 0 so my result is different.

Is there a way to get array0 always first?

In my dashboard screenshot at that moment it was ok. And when you see the chart you see it switched.

I hope I'm clear...

 ![34](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/3b5aa756c2ea30f249cd95900aa25858bab88ddb.png)

 ![iphone](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/bc179bbc64fe2ca6e8b9837ae49beee7d0916551.jpeg)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 July 2019 20:50 UTC](https://discourse.nodered.org/t/array-changes-after-a-time/13414/2 "2019-07-17T20:50:01Z")

</div>

How have you configured the Join node? If you set it to generate key/value pairs using the topic as the key, and make sure the two incoming messages have different topics, then you will know which one is which.

---

<div class="post-metadata">

**Author:** ![debouttek](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@debouttek](https://discourse.nodered.org/u/debouttek)\
**Post date:** [18 July 2019 05:59 UTC](https://discourse.nodered.org/t/array-changes-after-a-time/13414/3 "2019-07-18T05:59:24Z")

</div>

I used ANY ARRAY

 ![31](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c62324b67713032b875c42171869b3ecd3a8e548.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 July 2019 06:14 UTC](https://discourse.nodered.org/t/array-changes-after-a-time/13414/4 "2019-07-18T06:14:23Z")

</div>

Have you tried my suggestion to use key/value pairs instead?
