How to create an array of characters from a string in Power Automate

Hello everyone and welcome to my blog. In today’s blog I will discuss show how you can create an array from string in Power Automate.

Suppose I have the string Microsoft. I want to create an array out of the string, basically to return an array – [“M”, “i”, “c”, “r”, “o”, “s”, “o”, “f”, “t”]

Power Automate has inbuilt function – array and from the documentation it seems that it should create an array from a string.

Let’s try that out. Below is the array function in action. If you observe the output here, it basically creates an array with a single item and the item is the whole string.

Not exactly the way I wanted my output. My requirement of character array output is not achieved.

If you are thinking the split function with empty delimiter shall work, it won’t work too. The below formula shall return the same output, as returned by array function.

split('Microsoft', '')

So let’s look at working solution here. If you are thinking there is an out of the box function, well there isn’t. We will work our way to create the array of characters.

The first step is to declare an Array variable.

The next step is to use the Do Until loop. Iterate the Do Until loop till the length of the string is equal to the length of the array.

If condition formula (advanced mode)
@equals(length(variables('varArrTestString')), length(variables('varTestString')))

Within the Do Until, add each character of the string to the Array variable.

substring(variables('varTestString'),iterationIndexes('Do_until'),1)

Observe I am using the iterationIndexes function. It’s a out of the box function available in Do Until loop to provide the iteration count.

That’s all with the flow construct. Now when you run the flow, you will see the output as an array of characters from the string input.

I used the Compose action to display the array variable.

Hope you liked the post. If this post has helped, you can buy me a coffee.

For similar interesting topics on Microsoft.NET and Power platform, you can subscribe to my blog using the Subscribe option on the right pane.

You can also check out the below posts.

Debajit Dutta
Business Solutions MVP

2 thoughts on “How to create an array of characters from a string in Power Automate”

  1. Hi Debajit,

    I’m a subscriber to your blog and really enjoy reading and learning from your posts.

    I was thinking that the relatively new Slice() function could also be used such as in Select action:

    SELECT action:
    [From]: range(0, length(outputs(‘Compose’)))
    [Map]: slice(outputs(‘Compose’), item(), add(item(), 1))
    Switch Map Mode to Text Mode

    Best wishes,

    Ellis

    1. Debajit Dutta (Business Solutions MVP)

      Yes absolutely there are multiple ways to do that. I tried to do it the simplest of ways. range function shall work too.

      Thanks for your inputs and reading my blog.

      -Debajit

Comments are closed.