December 4, 2024

The array function will convert any value into an array. By any value, I mean one value only! The point of this function is not to parse a string and break it down into multiple elements in an array (for that, check the createArray function). Although it’s not used a lot, this function provides two steps in one. Create an array and populate it with data.

You can achieve the same with a “createArray function” with only one parameter, so you may wonder why Microsoft created this function. The reason is consistency. Since we have other functions like the “int function” for example, where we convert a value to an integer value, the same happens with the “array function”. We’re converting or “casting” a value into an array. With this Microsoft keeps the name of the type (int, float, array) as the function to convert the value so that you always know that to convert to something you use its name as the function.

Usage

It follows a simple pattern where you provide any value (string, boolean, int, float, etc.), and it will return an array with that value as the first element.

Example:

Let’s start with a simple example:

array('Manuel')

will return 

[
  "Manuel"
]

It works with all the other types that you would expect:

array(15)

will return 

[
  15
]

Floats:

array('3.14')

will return 

[
  3.14
]
Please don’t forget that if you write 3,14 instead of 3.14.
Because of the comma, Power Automate will consider that you’re providing two parameters instead of a float value
array(true)

will return 

[
  true
]

Limitations

You can only provide one parameter. There is another function (the createArray function) where you can provide multiple objects, and it will create an array with multiple elements.

Recommendations:

Here are some things to keep in mind.

Don’t nest

There’s no real reason to do it, but if you find yourself in a situation where you have nested array functions in a formula, you should review it and make everything more straightforward.

Sources:

Microsoft’s array Function Reference

Back to the Power Automate Function Reference.

Photo by davisuko on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

Leave a Reply

Your email address will not be published. Required fields are marked *

Mastodon