Recently, I have worked with the Leave Approval Process system, which enables employees to submit their requests through Microsoft Forms, and the responses are stored in a SharePoint list. Microsoft Forms has an Email field, where I need to save emails to a SharePoint list.
Here, I faced an Issue: The data is coming in an Array of Emails ending with a semicolon(;). To store the values in a SharePoint list, I need to separate the emails with commas.
This can be achieved by using the replace() function in Power Automate.
In this tutorial, I will explain how to replace value in an array using Power Automate with the following examples.
- Replace a string in an Array in Power Automate
- Replace Object in Array in Power Automate
- Replace Special Characters in an Array in Power Automate
Replace String in an Array using Power Automate
Suppose, let’s take an array like this. In the below array value, I wanted to replace a String value from ‘Power Apps‘ to ‘Power BI‘.
[
{
"Category": "Connector",
"Value": "SharePoint"
},
{
"Category": "Tool",
"Value": "Power Automate"
},
{
"Category": "Tool",
"Value": "Power Apps"
}
]Do follow the steps below to replace a string value in Array Power Automate:
- Browse make.powerautomate.com to open the Power Automate Home page. Create an Instant cloud flow that can be triggered manually with a single button click.
- Then, add an “Initialize variable” action and set the variable’s name, type as Array, and value to empty.

- Next to that, add a “Compose” action with the array values as shown in the screenshot below.

- Then, add an Apply to each loop action and select an output from previous steps to: Choose Compose Outputs.

- Inside the loop, add “Append to array variable” action and select Name of Array variable from the previous action and Value as below.
{
"Category": "@{item()?['Category']}",
"Value": "@{replace(item()?['Value'],'Power Apps','Power BI')}"
}
- To display the replaced string, take a “Compose” action. Provide input parameters with Initialize variable [Power Platform].

Click the Save button to save the flow and run it manually. When the flow runs successfully, you can see the result in the Compose action outputs.
Output:

This is how you can replace a string from an array using Power Automate.
Check out Create an Array From SharePoint List Items Using Power Automate
Replace Object Value from an Array using Power Automate
Now, we will see how to replace multiple object values in an array using Power Automate.
Below, I will work with an array containing multiple objects, as shown in the code below. In the given array, I want to replace the Status of objects whose value is ‘Pending’ with the value ‘In Progress’.
[
{
"TaskID": "T001",
"TaskName": "Create Power Platform PDF",
"Status": "Pending"
},
{
"TaskID": "T002",
"TaskName": "Develop Site Page",
"Status": "Pending"
},
{
"TaskID": "T003",
"TaskName": "Create a Web Part",
"Status": "In Progress"
},
{
"TaskID": "T003",
"TaskName": "Create a Site Page",
"Status": "Completed"
}
]Here, I will create an Instant cloud flow in Power Automate.
See the steps below:
- Into the Power Automate flow, add an “Initialize variable” action. Provide name, type as Array, and value with multiple array objects as below.

- Now, add “Select” flow action, and set the required parameters as below.
- From: Take the initialized variable output from the previous step.
- Map: Follow the table below
| Key | Value |
| TaskID | item()?[‘TaskID’] |
| TaskName | item()?[‘TaskName’] |
| Status | if(equals(item()?[‘Status’],’Pending’),replace(item()?[‘Status’],’Pending’,’In Progress’),item()?[‘Status’]) |

- Then, add a “Set variable” action to see the replaced item values. Provide the parameters.
- Name: Select the Array variable from the drop-down options.
- Value: Choose the output of the Select action from the dynamic content.

- Once the flow is ready, click the Save button to save the flow. Then, run the flow manually. The result can be seen in Set variable outputs.
Output:

Check out How to Initialize Object Variable in Power Automate
Replace Special Character in Array using Power Automate
Suppose we consider an Array of Emails, as shown in the code below. From the below array, I’d like to replace the semicolon (;) with a blank at the end of the email addresses.
[
{
"Email": "[email protected];"
},
{
"Email": "[email protected];"
},
{
"Email": "[email protected];"
}
]By following the above examples, you already know how to create a flow in Power Automate. Let’s start with the following steps.
- After that, add an “Initialize variable” action with empty array values. Provide name, type as Array, and value for an array variable.

- Now, add a “Compose” action to store the Array of Email addresses in the Inputs parameter.

- Then, add “Apply to each loop” by taking the outputs of the Compose action into it.

- Inside the loop, take the “Append to array variable” action, where we will append the email address by replacing the semicolon with a blank value. Set the parameters below.
- Name: Choose an initialized variable array from the drop-down.
- Value: Insert the code below.
replace(item()?['Email'],';','')
- To see the output, add one more Compose action and set the Input parameter.
- Inputs: Provide an initialized variable from the previous step.

Now the flow is ready, save and run it.
Output:

You can use the replace() function in Power Automate to replace a value in an array. Here, I have explained three different examples of replacing values in an array using Power Automate. Do let me know if you still have any questions in the comments section.
You may like the following tutorials:
- How to Use Append to String Variable Action in Power Automate?
- How to Set Variable Based on Condition in Power Automate?
- How to Filter an Array by Date in Power Automate?
- How to Reverse an Array in 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.