3 Ways to add a column to an array in Power Automate
When you have an array in Power Automate and you would like to add a column, you have 3 ways of doing this.
Arrays in Power Automate
In some of my posts in the past I already looked at arrays. In this post I will look at the different ways of adding a column to my array. I’ve found a number of ways of doing this and they all have their advantages.
- Constructing raw json
- Using AddProperty
- Using a select action
In my examples I’m going to use a compose action to create my initial array. But the arrays can really come from any other data source. This could be a SharePoint list, a SQL database or a table in Dataverse or anything else. Arrays are everywhere.
Creating the initial array
I’m creating the initial array, with two objects

Then as a run my flow I’m getting an array



Ok, that is good. Now I want to add the length of each title to the array.
Add a column to an array
The first option is to construct the objects inside an apply to each and then adding the Length property followed by an expression that calculates the length.
length(items('Apply_to_each')?['Title'])



That is easy enough when you only have one property to replicate and it also work probably when you have an array that has predictable propeties, but not every object in each array has to be the same, so this might be some thing that doesn’t always work.
If you have many unpredictable properties in your array you could consider the AddProperty function
AddProperty



Using the following expression you can add a column to whatever object you want. Giving the same result.
addProperty(items('Apply_to_each_2'),'Length', length(items('Apply_to_each_2')?['Title']))
The fast road to an additional column
Now you could use a select action and replicate all the properties, but that has got that same problem again of managing optional properties.



Using the addProperty in the select can be really powerful.



With the following expression we’re taking each item in the array and adding our property.
addProperty(item(),'Length', length(item()?['Title']))
Advantages of this last option. Only 1 action used, it is fast and it is easy to understand.


