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.
Then, provide a flow name and select Manually trigger a flow action. Then click on Create.
Now, you can see the “manual trigger a flow action” is added to the flow page in Power Automate.
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
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'),',')
4. Next, save the flow and run the flow manually; you can see the strings are converted to an array in Power Automate.
This is how to convert the string into an array using split() in 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.
Then, provide a flow name and select the “Manually trigger a flow” action. Then click on Create.
You can see the “Manually trigger a flow action” is added to the flow page in Power Automate.
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
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)
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.
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.
You may like the following tutorials:
- Convert String to Integer in Power Automate
- Convert String to Float in Power Automate
- Convert Percentage to Whole Number in Power Automate
- Convert a Number to Hexadecimal in Power Automate
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com