Convert a String to an Array in Power Automate

Do you want to convert a string to an array in Power Automate? In this Power Automate tutorial, we will see how to convert a string to an array in Power Automate.

Here, we will convert the topics below:

  • How to convert string to an array using split() in Power Automate
  • How to convert string to an array using chunk() in Power Automate

Convert string to an array using split() in Power Automate

Here, we will see how to convert a string to an array using split() in Power Automate.

For example, we have a list of names, i.e., Ron, Sam, John, and we want to convert it into an array, i.e. [“Ron”, “Sam”, “John”]. To do this, we will use the split () in Power Automate.

Split() in Power Automate will take the string and convert it into an array based on the delimiter.

Syntax:

split(string, delimiter)

1. Open Power Automate Cloud, then click on +Create -> select Instant Cloud Flow.

How to convert string to array in Microsoft power automate

Then, provide a flow name and select Manually trigger a flow action. Then click on Create.

How to convert string to array Microsoft power automate

Now, you can see the “manual trigger a flow action” is added to the flow page in Power Automate.

power automate convert string to array

2. We will initialize a string variable; for this, click on +New step -> select Initialize variable action. Then provide the below information:

  • Name: Provide the name of the variable
  • Type: Provide the type as a string
  • Value: Provide the value like below
Microsoft power automate convert string to array

3. We will convert the string to an array; for this, click on the +New step -> select Compose action. Then provide the below information:

  • Inputs: Provide the below expression:
split(variables('str'),',')
convert string to array Microsoft power automate

4. Next, save the flow and run the flow manually; you can see the strings are converted to an array in Power Automate.

convert string to array  power automate

This is how to convert the string into an array using split() in Power Automate.

See also  How to add Site columns to SharePoint content type using Power Automate?

Convert string to an array using chunk() in Power Automate

Here, we will see how to convert a string to an array using chunk() in Power Automate.

For example, I want to create an array of characters [‘A’,’u’,’t’,’o’,’m’,’a’,’t’,’e’] from a string ‘Automate’. To do this, we will use chunk() in Power Automate.

The chunk() in Power Automate splits a string based on the character length. Also, it will divide a string into equal parts based on a given number of characters,

Syntax

chunk(collection: array|string, length: int)

Let’s see how we can do it using Power Automate.

1. Open Power Automate Cloud, then click on +Create -> select Instant Cloud Flow.

How to convert string to array in Microsoft power automate

Then, provide a flow name and select the “Manually trigger a flow” action. Then click on Create.

How to convert string to array Microsoft power automate

You can see the “Manually trigger a flow action” is added to the flow page in Power Automate.

power automate convert string to array

2. We will initialize a string variable; for this, click on +New step -> select Initialize variable action. Then provide the below information:

  • Name: Provide the name of the variable
  • Type: Provide the type as a string
  • Value: Provide the value like below
convert string to array in power automate

3. We will convert the string to an array of characters; for this, click on the +New step -> select Compose action. Then provide the below information:

  • Inputs: Provide the below expression:
chunk(variables('str'),1)
How to convert string to array in power automate

4. Next, save the flow and run the flow manually; you can see the strings are converted to an array of characters in Power Automate.

How to convert string to array power automate

This is how to convert a string to an array in Power Automate.

Conclusion

In this Power Automate tutorial, we saw how to convert a string to an array in Power Automate using the split() and the chunk() functions in Power Automate.

See also  How to Create CSV File in SharePoint Using Power Apps?

You may like the following tutorials:

>