# Deduct old payload from new payload

**URL:** <https://discourse.nodered.org/t/deduct-old-payload-from-new-payload/259>\
**Category:** General\
**Created:** [20 May 2018 17:44 UTC](https://discourse.nodered.org/t/deduct-old-payload-from-new-payload/259 "2018-05-20T17:44:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcusrs](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@Marcusrs](https://discourse.nodered.org/u/Marcusrs)\
**Post date:** [20 May 2018 17:44 UTC](https://discourse.nodered.org/t/deduct-old-payload-from-new-payload/259/1 "2018-05-20T17:44:31Z")

</div>

Hi,

I am currently getting a payload that is perfectly fine to further use, but I would also like to deduct the previous payload

Ideally something like

`payload=new.payload-old.payload`

Is this easily done in a function somehow?

Best regards

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [20 May 2018 19:06 UTC](https://discourse.nodered.org/t/deduct-old-payload-from-new-payload/259/2 "2018-05-20T19:06:11Z")

</div>

Take a look at [https://nodered.org/docs/writing-functions#storing-data](https://nodered.org/docs/writing-functions#storing-data)

---

<div class="post-metadata">

**Author:** ![Marcusrs](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@Marcusrs](https://discourse.nodered.org/u/Marcusrs)\
**Post date:** [21 May 2018 18:43 UTC](https://discourse.nodered.org/t/deduct-old-payload-from-new-payload/259/3 "2018-05-21T18:43:01Z")

</div>

Thank you for the link, unfortunately I wasn’t able to derive anything that worked…

Is it some sort of buffer or similar I need to do?

Best regards

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [21 May 2018 20:56 UTC](https://discourse.nodered.org/t/deduct-old-payload-from-new-payload/259/4 "2018-05-21T20:56:02Z")

</div>

No node red doesn’t have a “buffer” of previous messages. So if you want to remember the previous message you will have to choose to store it, which is why I linked to the page that shows you how.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [21 May 2018 22:00 UTC](https://discourse.nodered.org/t/deduct-old-payload-from-new-payload/259/5 "2018-05-21T22:00:40Z")

</div>

Just to give a bit more of a pointer, the docs @ukmoose has linked to shows you how to store data in `flow context`. This can be used to store a message’s payload and retrieve it the next time a Function is called - allowing you to perform the operation you want.
