# How can I collect all data in one array

**URL:** https://discourse.nodered.org/t/how-can-i-collect-all-data-in-one-array/70833
**Category:** General
**Tags:** node-red-dashboard, database, function-node
**Created:** [18 November 2022 13:36 UTC](https://discourse.nodered.org/t/how-can-i-collect-all-data-in-one-array/70833 "2022-11-18T13:36:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Remili158](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@Remili158](https://discourse.nodered.org/u/Remili158)
#### Post date: [18 November 2022 13:36 UTC](https://discourse.nodered.org/t/how-can-i-collect-all-data-in-one-array/70833/1 "2022-11-18T13:36:43Z")

</div>

Hello everyone,

I want to collect data coming from a sensor in an array. The sensor output is actualised every 1 sec. Every time a new value comes only 1 value will be stored in my array and the other values are 0.  
here a simple example : 3 values injected 21, 10 and 15, I get [21 0 0] , [0 15 0] and [0 0 10].  
I want to get this array [21 15 10] , where every value that changes is stored.

Any ideas how can I sove this problem with function or any other Note?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/e/0e1450fcdce55f981ba5b978765ab643f7d868e4.png)

---

<div class="post-metadata">

### Author: ![gemini86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gemini86/32/70967_2.png) [@gemini86](https://discourse.nodered.org/u/gemini86)
#### Post date: [18 November 2022 13:39 UTC](https://discourse.nodered.org/t/how-can-i-collect-all-data-in-one-array/70833/2 "2022-11-18T13:39:05Z")

</div>

using the join node possibly? play around with it.

```auto
[{"id":"cec5d1533e6f103e","type":"join","z":"e9ac22a1.fe877","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"10","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":210,"y":560,"wires":[[]]}]

```

---

<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: [2 December 2022 13:39 UTC](https://discourse.nodered.org/t/how-can-i-collect-all-data-in-one-array/70833/3 "2022-12-02T13:39:29Z")

</div>

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