# How to compare consecutive payloads in node-red?

**URL:** <https://discourse.nodered.org/t/how-to-compare-consecutive-payloads-in-node-red/2637>\
**Category:** General\
**Created:** [28 August 2018 13:06 UTC](https://discourse.nodered.org/t/how-to-compare-consecutive-payloads-in-node-red/2637 "2018-08-28T13:06:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asw](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@Asw](https://discourse.nodered.org/u/Asw)\
**Post date:** [28 August 2018 13:06 UTC](https://discourse.nodered.org/t/how-to-compare-consecutive-payloads-in-node-red/2637/1 "2018-08-28T13:06:47Z")

</div>

Hello everyone ,  
I am relatively new to node-red , I wanted to know How to compare consecutive payloads in node-red , I am actually getting stream of payloads from same source and wanted to compute values , for this processing i need to compare the payloads . If anyone knows about it please help!!  
Regards  
Aalhad

---

<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:** [28 August 2018 13:20 UTC](https://discourse.nodered.org/t/how-to-compare-consecutive-payloads-in-node-red/2637/2 "2018-08-28T13:20:30Z")

</div>

You need to save the payload in the node context and then you can pick it up the next time round.  
See the section on Storing Data in  
[https://nodered.org/docs/writing-functions](https://nodered.org/docs/writing-functions)

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [28 August 2018 13:20 UTC](https://discourse.nodered.org/t/how-to-compare-consecutive-payloads-in-node-red/2637/3 "2018-08-28T13:20:53Z")

</div>

You could use a join node and tell it to wait for 2 consecutive values and put them in an array. You can then use array arithmetic on the values.  
 ![Screenshot%20at%202018-08-28%2014-20-20](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7d940d9ea5a01100eb8f44843313dc74d561d945.png)

---

<div class="post-metadata">

**Author:** ![ray](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ray/32/1146_2.png) [@ray](https://discourse.nodered.org/u/ray)\
**Post date:** [29 August 2018 01:59 UTC](https://discourse.nodered.org/t/how-to-compare-consecutive-payloads-in-node-red/2637/4 "2018-08-29T01:59:22Z")

</div>

I believe that the collector node might do this for you. I use it to keep repeated peeks at a mail stream from repeating the same messages.

---

<div class="post-metadata">

**Author:** ![Asw](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@Asw](https://discourse.nodered.org/u/Asw)\
**Post date:** [29 August 2018 04:37 UTC](https://discourse.nodered.org/t/how-to-compare-consecutive-payloads-in-node-red/2637/5 "2018-08-29T04:37:56Z")

</div>

Thanks colin ,ghayne and ray i am working on the methods you guyz suggested , will come back to you guyz on the same.

Regards,  
Aalhad
