Recently, during a product development, I faced a scenario where I had to combine data from multiple sources into a single array. In Power Automate, merging arrays is frequently needed when dealing with dynamic content like SharePoint lists, Excel rows, or API responses. Whether you’re aggregating data for reports, combining multiple lists, or preparing JSON payloads, merging arrays helps us organize your data efficiently.
I will show you how to merge arrays in Power Automate using different techniques in this tutorial. Whether you need to combine data from SharePoint lists, enhance arrays with additional details, or handle duplicates efficiently.
Merge Arrays in Power Automate
Follow the examples below:
Example: 1 [Combine Two Arrays of Data into a Single Array]
Imagine you are managing an Employee Training Program with two SharePoint lists i.e.:
- Registered Employees: Stores employees who have signed up for training.

- Waitlisted Employees: Stores employees on the same program’s waiting list.

Now, I want to merge both lists into a single array and send an email notification containing the combined list of all employees (registered + waitlisted).
Now follow the below steps:
1. In the Power Automate, click the Instant Cloud flow, enter the Flow name, and choose the trigger flow (i.e., manually trigger a flow).

2. Add Initialize variable action and provide the below parameters to store Registered Employees SharePoint list value in an array format:
- Name: Provide name as varRegisteredEmployees.
- Type: Select type as Array.
- Value: Leave as blank.

3. Add Get items action and provide the below parameters to retrieve the Registered Employees SharePoint list value:
- Site Address: Select your SharePoint site address.
- List Name: Select your SharePoint list name.

4. Next, add the ‘Apply to each’ action and provide the body output from the ‘Get items’ action. Inside the ‘Apply to each’ action, add the ‘Append to array variable’ action and use the following parameter:
- Name: Select the above array variable.
- Value: Provide below:
{
"Employee Name": "@{items('For_each')?['EmployeeName']}",
"Training Program": "@{item()?['TrainingProgram']}"
}
5. Again, add the Initialize variable action and provide the below parameters to store the Waitlisted Employees SharePoint list value in an array format:
- Name: Provide name as varWaitlistedEmployees.
- Type: Select type as Array.
- Value: Leave as blank.

6. Add Get items action and provide the below parameters to retrieve the Waitlisted Employees SharePoint list value:
- Site Address: Select your SharePoint site address.
- List Name: Select your SharePoint list name.

7. Again, add the ‘Apply to each‘ action and provide the body output from the ‘Get items’ action. Inside the ‘Apply to each’ action, add the ‘Append to array variable’ action and use the following parameter:

8. Then add a Compose action and provide the bellow expression to combine the above two arrays:
union(variables('varRegisteredEmployees'),variables('varWaitlistedEmployees'))
Now, click save and run the flow manually after it runs successfully. Click the compose action to see that the two arrays are combined.
[
{
"Employee Name": "John Doe",
"Training Program": "Power Automate Basics"
},
{
"Employee Name": "Jane Smith",
"Training Program": "Power Apps Essentials"
},
{
"Employee Name": "Alice Brown",
"Training Program": "Power Automate Basics"
},
{
"Employee Name": "Mike Johnson",
"Training Program": "SharePoint Fundamentals"
},
{
"Employee Name": "Tom Clark",
"Training Program": "Power Automate Basics"
},
{
"Employee Name": "Sarah White",
"Training Program": "Power Automate Basics"
}
]
Example: 2 [Merge Two Arrays to Create a Detailed Report]
Suppose you have two arrays, one with person names and the other with their ages. I want to create a single array containing complete details (ID, name, and age). The result will be formatted as an HTML table and sent via email.
Now follow the below steps:
1. In the Power Automate, click the Instant Cloud flow, enter the Flow name, and choose the trigger flow (i.e., manually trigger a flow).

2. Add Initialize variable actions and provide the below parameters:
- Name: varPersonName
- Type: Array
- Value:
[
{ "id": 1, "name": "John" },
{ "id": 2, "name": "Jane" },
{ "id": 3, "name": "Michael" }
]
3. Add Initialize variable actions and provide the below parameters:
- Name: varPersonAge
- Type: Array
- Value:
[
{ "id": 1, "age": 30 },
{ "id": 2, "age": 25 },
{ "id": 3, "age": 40 }
]
4. Again, add Initialize variable actions and provide the below parameters:
- Name: varPersonDetails
- Type: Array
- Value: Leave blank

5. Add an Apply to each action to loop through the first array varPersonName:
- Select an output from previous steps: Choose varPersonName from dynamic content.
@{variables('varPersonName')}
6. Inside the loop, add a Filter array action to find the matching entry in the second array var
- From: Select varPersonAge from dynamic content.
- Condition:
- Left Value: item()?[‘id’]
- Operator: is equal to
- Right Value: items(‘Apply_to_each’)?[‘id’]

7. Add an Append to array variable action to merge the data:
- Name: Select varPersonDetails from the dropdown.
- Value:
{
"id": "@{item()?['id']}",
"name": "@{item()?['name']}",
"age": "@{first(body('Filter_array'))?['age']}"
}
8. Add a Create HTML table action to generate a table from the merged array:
- From: Select PersonDetails from dynamic content.

9. Add a Send an email (V2) action:
- To: Provide the recipient’s email address.
- Subject: “Merged Person Details Report”
- Body: Select the output of Create HTML table from dynamic content.

Save the flow and click the Test button. Select Manually to run the flow. Once the flow runs successfully, check your email to view the merged details in the HTML table.

Example – 3 [Merge Two Arrays with XML Transformation]
In the above example, we saw how to merge using another array. Now, I will show you how to do the same using XML transformation. Follow the steps below to achieve this:
1. Follow the same first three steps to create an Instant Cloud Flow and choose ‘Manually trigger a flow.’ Add three ‘Initialize variable’ actions to define the arrays.

2. Add a Compose action to wrap the PersonAge array in a root element and provide the below:
{
"root": {
"Array": @{variables('varPersonAge')}
}
}
3. Add another Compose action to convert the output of the previous step into XML format:
xml(outputs('Compose'))
4. Add a Select action to merge the two arrays.
- From: Select PersonName from dynamic content.
- Map: Click on the T icon to switch to text mode, then provide the below code:
{
"Id": @{item()?['id']},
"Name": @{item()?['name']},
"Age": @{xpath
(
outputs('Compose_1'),
concat('//Array[id/text()="', item()['id'], '"]/age/text()')
)?[0]}
}
5. Then add a Compose action and provide the above select action output from dynamic content.

Now, click save and run the flow manually after it runs successfully. Click the compose action to see that the two arrays are combined.
[
{
"Id": 1,
"Name": "John",
"Age": "30"
},
{
"Id": 2,
"Name": "Jane",
"Age": "25"
},
{
"Id": 3,
"Name": "Michael",
"Age": "40"
}
]
Example – 3 [Joining Arrays While Keep Duplicates]
Here, I want to join two arrays while keeping duplicates intact using the convert-to-string and replace method in Power Automate. This method is efficient and avoids complex looping or conditions.
Now follow the below steps:
1. Log in to Power Automate and click +Create in the left navigation. Select Instant Cloud Flow, provide a name for the flow (e.g., ‘Join Power Platform Arrays with Duplicates’), and choose Manually trigger a flow. Then, click Create.

2. Add Initialize variable actions and provide the below parameters:
- Name: varProductsGroup1
- Type: Array
- Value:
[
"Power Apps",
"Power Automate",
"Power BI",
"Dataverse",
"AI Builder"
]
3. Add Initialize variable actions and provide the below parameters:
- Name: varProductsGroup2
- Type: Array
- Value:
[
"Power BI",
"Power Pages",
"Power Automate",
"Power Virtual Agents",
"Dataverse"
]
4. Add a Compose action to merge the arrays using the below expression:
json(replace(concat(string(variables('varProductsGroup1')), string(variables('varProductsGroup2'))), '"]["', '","'))- string(variables(‘ProductsGroup1’)): Converts the first array into a string.
- string(variables(‘ProductsGroup2’)): Converts the second array into a string.
- concat(): Combines the two stringified arrays into a single string.
- replace(): Replaces the ending/starting brackets (“][“) between the two stringified arrays with a comma and double quotes (“,”) to maintain the JSON array format.
- json(): Converts the resulting string back into a valid array.

Save the flow, click Test, and manually run it after it runs successfully. Check the output of the Compose action.
[
"Power Apps",
"Power Automate",
"Power BI",
"Dataverse",
"AI Builder",
"Power BI",
"Power Pages",
"Power Automate",
"Power Virtual Agents",
"Dataverse"
]
Conclusion
In this tutorial, I covered various ways to merge arrays in Power Automate, including combining two SharePoint lists into a single array, merging arrays with additional details for reporting, using XML transformation to join arrays, and handling duplicates while merging arrays.
Related Power Automate tutorials:
- Power Automate Array Variable
- Delete All Rows in Excel Using Power Automate
- Power Automate Split String into Array
- Various Ways to Sort Arrays in Power Automate
- Create an Array From a String Using Power Automate

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.