Do you want to replace the comma with a new line in Power Automate? Then follow this Power Automate tutorial; here, I have explained how to replace commas with new lines in Power Automate with different examples.
Sometimes, we must replace the commas with new lines using Power Automate flow. For example, if we have values like below
new york,california,chicago
We must display the values below by replacing the comma with a new line using the flow.
new york
california
chicago
Well, here I will explain three different examples of how to replace commas with new lines using the Replace() function in Power Automate.
In this first example, I will show you how to replace a comma in a string with a new line using Power Automate flow.
In the second example, I will explain how to use flow to replace commas in an array of objects with new lines.
Finally, I will show you how to replace commas presented in multi-line text filed in the SharePoint list with new lines using Power Automate flow.
Now, we will create a flow to replace the comma with a new line using Power Automate flow.
Replace Commas with New Lines in Power Automate
Let us see how to replace commas with new lines using Power Automate.
Example -1: (Using String Values)
In this example, we will see how to replace a comma in a string with a new line using Power Automate flow.
Step-1:
Create an instant cloud flow with a manual trigger. Add a new step and select initialize variable action. Provide the required parameters.
- Name – Enter the variable name
- Type – Choose the variable type as String
- Value – pass the below string values.
Power Apps, Power Automate, Power BI, Power Virtual Agent, Power Pages
Step-2:
Now, to replace the comma with a new line, Add a compose data operation and pass the below expression:
replace(variables('Technologies'),',',decodeUriComponent('%0A'))
Step-3:
Save and run the flow; once the flow runs successfully, like below, it replaces the comma and displays the string value in the new line in the outputs of the compose data operation.
This is how to replace a comma in a string value with a new line using Power Automate flow.
Example -2: (Using Array of Objects)
In this example, we will see how to use flow to replace commas in an array of objects with new lines.
Step-1:
Create an instant cloud flow with a manual trigger. Add a new step and select initialize variable action. Provide the required parameters.
- Name – Enter the variable name
- Type – Choose the variable type as Array
- Value – pass the below array of object values
[
{
"Technologies": "Power Apps,Power Automate,Power BI"
},
{
"Technologies": "Power Virtual Agent,Power Pages"
}
]
Step-2:
Add a new step, choose Apply to each control, and pass the initialized array variable from the dynamic content
Select a new step, and add a compose data operation to replace the comma with a new line using flow. Pass the below expression as an input.
replace(items('Apply_to_each')?['Technologies'],',',decodeUriComponent('%0A'))
Step-3:
Save and run the flow once the flow runs successfully like below:
We can see, it replaces the comma and displays the output value in a new line for the first set array of objects using flow.
Similarly, when we select the next option, it replaces the comma and displays the output value in a new line for the second set array of objects using flow.
This is how to use flow to replace commas in an array of objects with new lines.
Example -3: (Using SharePoint list)
In this example, we will see how to replace commas presented in multi-line text filed in the SharePoint list with new lines using flow.
Here, I am going to use the below Technologies SharePoint list, Consisting of
- Technology – default title column
- Description – Multi line of text type
Now, we will create a flow to replace the comma with a new line for the Description column presented in the SharePoint list.
Step-1:
Create an instant cloud flow with a manual trigger, select Get items action from action triggers, and configure the required parameters.
- Site Address – select the SharePoint site address from the dropdown
- List Name – choose the SharePoint list. Here, I have selected my technology list
Step-2:
Add a new step, choose Apply to each control, and pass the value from the dynamic content
Select a new step, and add a compose data operation to replace the comma with a new line using flow. Pass the below expression as an input, which replaces the comma with a new line for the description field.
replace(items('Apply_to_each')?['Description'],',',decodeUriComponent('%0A'))
Once the comma has been replaced with the new line, we will update the SharePoint list description field with the replaced values.
For that, Add a new step, choose the Update item action from action triggers, and provide the below parameters:
- Site Address – select the SharePoint site address from the dropdown
- List Name – choose the SharePoint list. Here, I have selected my technology list
- ID – choose the ID from dynamic content values
In the Description field, pass the outputs of the compose data operation.
outputs('Compose')
Step-3:
Save and run the flow once the flow runs successfully like below:
We can see it replaces the comma with the new line for the Description field presented in the SharePoint list.
This is how to replace commas presented in multi-line text filed in the SharePoint list with new lines using Power Automate.
Conclusion
I hope you got an idea to replace a comma with a new line using Power Automate flow.
So here, I have explained three different examples of how to replace commas with new lines using the Replace() function in Power Automate.
In this first example, I showed you how to replace a comma in a string with a new line using Power Automate. In the second example, I explained how to use flow to replace commas in an array of objects with new lines. Finally, I have shown you how to replace commas presented in multi-line text filed in the SharePoint list with new lines using Power Automate flow.
You may like the following tutorials:
- Convert a String to an Integer in Power Automate
- Convert String to GUID in Power Automate
- Convert a String to a Decimal Number in Power Automate
- Convert String to Float in Power Automate
- How to Remove line breaks from text in Power Automate?
After working for more than 15 years in Microsoft technologies like SharePoint, Office 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 (9 times). I have also worked in companies like HP, TCS, KPIT, etc.