# Optimal way to merge two arrays based on a common field?

**URL:** <https://community.make.com/t/optimal-way-to-merge-two-arrays-based-on-a-common-field/87652>\
**Category:** Questions\
**Tags:** arrays, scenario, functions\
**Created:** [July 19, 2025, 10:59pm UTC](https://community.make.com/t/optimal-way-to-merge-two-arrays-based-on-a-common-field/87652 "2025-07-19T22:59:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![soso\_pkhakadze](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@soso\_pkhakadze](https://community.make.com/u/soso_pkhakadze)\
**Post date:** [July 19, 2025, 10:59pm UTC](https://community.make.com/t/optimal-way-to-merge-two-arrays-based-on-a-common-field/87652/1 "2025-07-19T22:59:13Z")

</div>

I have two different arrays in array aggregators with multiple collections that I need to merge efficiently:

- **Array 1:** Contains `firstname`, `lastname`, and `email` (10 records).
- **Array 2:** Contains `age` and `email` (same 10 emails).

I need to combine them into one array with all fields (`firstname`, `lastname`, `age`, `email`) using `email` as the key.

**For Example:**

Array 1:  
[{  
“firstname”: “A”,  
“lastname”: “AA”,  
“email”: “[A@gmail.com](mailto:A@gmail.com)”  
},  
{  
“firstname”: “B”,  
“lastname”: “BB”,  
“email”: “[B@gmail.com](mailto:B@gmail.com)”  
},  
{  
“firstname”: “C”,  
“lastname”: “CC”,  
“email”: “[C@gmail.com](mailto:C@gmail.com)”  
},  
…  
]

Array 2:  
[{  
“age”: “20”,  
“email”: “A@gmail com”  
},  
{  
“age”: “21”  
“email”: “B@gmail com”  
},  
{  
“age”: “22”  
“email”: “C@gmail com”  
},  
…  
]

Desired Output:  
[{  
“firstname”: “A”,  
“lastname”: “AA”,  
“age”: “20”,  
“email”: “A@gmail com”  
},  
{  
“firstname”: “B”,  
“lastname”: “BB”,  
“age”: “21”,  
“email”: “B@gmail com”  
},  
{  
“firstname”: “C”,  
“lastname”: “CC”,  
“age”: “22”,  
“email”: “C@gmail com”  
},  
…  
]

I tried to use iterator but it would cost me as many operations as many emails I have and I wanna know **Is there a way to make this efficiently? maybe with built-in Make funcitons?**

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Prem\_Patel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/prem_patel/32/93657_2.png) [@Prem\_Patel](https://community.make.com/u/Prem_Patel)\
**Post date:** [July 20, 2025, 4:46am UTC](https://community.make.com/t/optimal-way-to-merge-two-arrays-based-on-a-common-field/87652/2 "2025-07-20T04:46:28Z")

</div>

Hey @soso_pkhakadze Welcome to the community!

Here is the easiest and optimal way to combine arrays. To do this, Follow this steps:

1. Iterate 1 array ideally with more items  

2. Use JSON aggregator with final array or JSON structure with combined items by clicking on Add in Data structure options and then add your sample json in generate option and save the structure. After that create mappings as shown in screenshot with the use of map function.

3. You can copy and replace items based on your mapping : `{{first(map(66.array2; "age"; "email"; 68.email))}}`

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/e/f/ef4addddfd91e97c2ae40edc6a064748ee5f1ec1.png)

1. If needed, you can parse the JSON aggregated and When you run this part again, you will get desired output with combined items  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/e/0/e03903ee49ab3298de6baabaab0027559bef722e.png)

This will help in merging 2 Arrays based on common key as “email”

Best,  
@Prem_Patel

---

<div class="post-metadata">

**Author:** ![soso\_pkhakadze](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@soso\_pkhakadze](https://community.make.com/u/soso_pkhakadze)\
**Post date:** [July 20, 2025, 2:53pm UTC](https://community.make.com/t/optimal-way-to-merge-two-arrays-based-on-a-common-field/87652/3 "2025-07-20T14:53:06Z")

</div>

Thanks a lot! This was exactly what I was looking for!

---

<div class="post-metadata">

**Author:** ![Prem\_Patel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/prem_patel/32/93657_2.png) [@Prem\_Patel](https://community.make.com/u/Prem_Patel)\
**Post date:** [July 20, 2025, 3:12pm UTC](https://community.make.com/t/optimal-way-to-merge-two-arrays-based-on-a-common-field/87652/4 "2025-07-20T15:12:01Z")

</div>

Glad it helped you! @soso_pkhakadze

Best,  
@Prem_Patel

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [August 3, 2025, 2:57pm UTC](https://community.make.com/t/optimal-way-to-merge-two-arrays-based-on-a-common-field/87652/5 "2025-08-03T14:57:32Z")

</div>


