# Create node red array with equal values

**URL:** <https://discourse.nodered.org/t/create-node-red-array-with-equal-values/80829>\
**Category:** General\
**Created:** [26 August 2023 18:23 UTC](https://discourse.nodered.org/t/create-node-red-array-with-equal-values/80829 "2023-08-26T18:23:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [26 August 2023 18:23 UTC](https://discourse.nodered.org/t/create-node-red-array-with-equal-values/80829/1 "2023-08-26T18:23:05Z")

</div>

Hello!

Is it possible to put all values where the topic is the same in an array.

I have a list where there are several dates and they all have to be put together where the topic is the same to make them into an array.

It's like a switch but you don't have to enter the value.

I hope that someone can help me there.

---

<div class="post-metadata">

**Author:** ![KAMERONSWENSON](https://avatars.discourse-cdn.com/v4/letter/k/df788c/32.png) [@KAMERONSWENSON](https://discourse.nodered.org/u/KAMERONSWENSON)\
**Post date:** [26 August 2023 18:27 UTC](https://discourse.nodered.org/t/create-node-red-array-with-equal-values/80829/2 "2023-08-26T18:27:13Z")

</div>

Do you want something like this?

Msg.topic = "TopicValue"  
Msg.payload = [date1, date2, date3, etc]

Not really visualizing what you want here

---

<div class="post-metadata">

**Author:** ![KAMERONSWENSON](https://avatars.discourse-cdn.com/v4/letter/k/df788c/32.png) [@KAMERONSWENSON](https://discourse.nodered.org/u/KAMERONSWENSON)\
**Post date:** [26 August 2023 18:28 UTC](https://discourse.nodered.org/t/create-node-red-array-with-equal-values/80829/3 "2023-08-26T18:28:58Z")

</div>

Or do you have an array of objects and want something like this

Msg.payload = [{"Date" : Date1}, {"Date": Date2}]

---

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [26 August 2023 18:33 UTC](https://discourse.nodered.org/t/create-node-red-array-with-equal-values/80829/4 "2023-08-26T18:33:06Z")

</div>

Hello!

Thanks for the reply.

It should then look like this.

 ![Bildschirmfoto 2023-08-26 um 20.30.29](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/d/7d447a85618cfede47a35de3d2e5c0b33f4fbef6.png)

Hello!

Thanks for the reply.

It should then look like this.

If the topic or article number is different then he should make the entry in a new array.

---

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [26 August 2023 18:50 UTC](https://discourse.nodered.org/t/create-node-red-array-with-equal-values/80829/5 "2023-08-26T18:50:31Z")

</div>

I just found something. it should be like node-red-contrib-merge-topic.

> **[node-red-contrib-merge-topic](https://flows.nodered.org/node/node-red-contrib-merge-topic/in/rAymDqDAlwbL)**
>
> Merges incoming messages into a new message whose payload is an array of the received messages - grouping per topic

Is there a better solution?

---

<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:** [25 October 2023 18:51 UTC](https://discourse.nodered.org/t/create-node-red-array-with-equal-values/80829/6 "2023-10-25T18:51:03Z")

</div>

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