# How to only return the msg with the highest payload parameter (wait and filter)

**URL:** <https://discourse.nodered.org/t/how-to-only-return-the-msg-with-the-highest-payload-parameter-wait-and-filter/10580>\
**Category:** General\
**Created:** [26 April 2019 18:25 UTC](https://discourse.nodered.org/t/how-to-only-return-the-msg-with-the-highest-payload-parameter-wait-and-filter/10580 "2019-04-26T18:25:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![swiftnesses](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@swiftnesses](https://discourse.nodered.org/u/swiftnesses)\
**Post date:** [26 April 2019 18:25 UTC](https://discourse.nodered.org/t/how-to-only-return-the-msg-with-the-highest-payload-parameter-wait-and-filter/10580/1 "2019-04-26T18:25:18Z")

</div>

Good day,

I have a function node that loops through an array and outputs 4 distinct messages via 4 different outputs. Each message has a unique indicator, i.e. 1m, 5m, 15m, 1hr.

Under certain circumstances, the node may output multiple msgs within a very short amount of time (less than a few seconds), because multiple criteria have been met.

I'd like to somehow wait after the first message is received, to see if other messages arrive, example:

1m is sent, wait to see if 5m, 15m, or 1 hr also arrive within a few seconds, if so, only send on the highest value, if not, return the original msg (in this case 1m).

How can I best achieve this?

Many thanks in advance.

P.S. My ideal scenario would be to state that criteria x and x and x was met, but I'm not sure if this is possible!

---

<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:** [26 April 2019 18:57 UTC](https://discourse.nodered.org/t/how-to-only-return-the-msg-with-the-highest-payload-parameter-wait-and-filter/10580/2 "2019-04-26T18:57:10Z")

</div>

push the positive result into an array.

Then do the analysis on the array before sending anything

---

<div class="post-metadata">

**Author:** ![swiftnesses](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@swiftnesses](https://discourse.nodered.org/u/swiftnesses)\
**Post date:** [26 April 2019 20:10 UTC](https://discourse.nodered.org/t/how-to-only-return-the-msg-with-the-highest-payload-parameter-wait-and-filter/10580/3 "2019-04-26T20:10:03Z")

</div>

So in essence, push all messages to an array and then analyse the array to see which has the highest value, then send it? Logical and very simple, thanks!
