How to Replace Commas with New Lines in Power Automate?

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
power automate replace comma with new line

Step-2:

See also  Power Apps Create Collection Using SharePoint List

Now, to replace the comma with a new line, Add a compose data operation and pass the below expression:

replace(variables('Technologies'),',',decodeUriComponent('%0A'))
How to Replace Commas with New Lines in Power Automate

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.

How to Replace Commas with New Lines in Power Automate flow

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"
  }
]
Replace Commas with New Lines in Power Automate flow

Step-2:

Add a new step, choose Apply to each control, and pass the initialized array variable from the dynamic content

Replace Commas with New Lines in Power Automate

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'))
Replace comma with new line in power automate

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.

Example to Replace Commas with New Lines in Power Automate

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.

Example to Replace Commas with New Lines in Power Automate flow

This is how to use flow to replace commas in an array of objects with new lines.

See also  Power Automate Send 7 or 14 Day Task Due Reminder Emails

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
Replace Comma with Next Line in Power Automate

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
Replace Comma with Next Line in Power Automate flow

Step-2:

Add a new step, choose Apply to each control, and pass the value from the dynamic content

Replace Comma with Next Line using Power Automate

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'))
Replace Comma with Next Line using Power Automate flow

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')
How to Replace Commas with New Lines using Power Automate flow

Step-3:

See also  Power Automate concat() Function [With Examples]

Save and run the flow once the flow runs successfully like below:

How to Replace Commas with New Lines using Power Automate

We can see it replaces the comma with the new line for the Description field presented in the SharePoint list.

power automate replace a comma with a new line

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:

>