5 Surprising Power Automate Select Action Tricks

5 Surprising Power Automate Select Action Tricks

The Power Automate select action can be used to do more than simply selecting the specified columns of an array. With it we can add new columns to an array, update existing values in an array, add an index number and more. The examples shared in this article will likely surprise you and lead to think of additional use cases.

Table of Contents
β€’ Select The Specified Columns Of An Array
β€’ Add A New Column To An Array
β€’ Add The Index Position For Each Item To An Array
β€’ Convert Text To A Number Column In An Array
β€’ Create An Array List Of Values With No Column Names




Select The Specified Columns Of An Array

The Power Automate Select action can be used to select specific columns from an array and remove the other columns. For example, assume there is an array of test scores with the columns: student, test and score. We can select the student and test columns and drop the score column.



Code

Map Student field:

item()?['Student']


Map Test field:

item()?['Test']



Result




Add A New Column To An Array

To add a new column to a Power Automate array we can use a combination of the select action and the addProperty function. First we switch the select action map field to text mode we make it display a single field. Then we input the addProperty function with the new column name and value. The select action loops over each row in the array and adds the new column.



Code

Map field:

addProperty(item(),'Passed',greaterOrEquals(int(item()?['Score']),50))



Result




Add The Index Position For Each Item To An Array

The index position (or row number) can be added to the array using the addProperty function. After switching the map field of the select action to text mode we can use a simple expression to insert and index number for each item. The index will start at 0 by default. If we wanted the index to start at 1 instead we could use the add function to increment the index by 1.



Code

From field:

range(0, length(variables('Test Scores')))


Map field:

addProperty(variables('Test Scores')[item()],'Index',item())



Result




Convert Text To A Number Column In An Array

Often times numbers are found as a text data type inside of an array. The setProperty function can be used to change a string column to a number column. We do this by adding the setProperty function to the map property of a select action supplying the column name and a function to convert to a new data type. In this example we use the int function to change the text string to an integer. We could also use the decimal function or the float function as well.



Code

Map field:

setProperty(item(),'Score',int(item()?['Score']))



Result




Create An Array List Of Values With No Column Names

A Power Automate array list is a list of values with no column names. They are helpful for finding a list of unique values and doing contains/does not contain comparisons. To create an array list add a select action and change the map field to text mode. Then we add the dynamic value for the field we want to create the array list for.



Code

Map field:

item()?['Student']



Result




Questions?

If you have any questions or feedback about 5 Surprising Power Automate Select Action Tricks please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

12 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Amy Schalla
Amy Schalla
3 months ago

Loved this article

Udula J
Udula J
3 months ago

Thanks for sharing Mat, love what can be done with addproperty and setproperty functions. Got my doubts on this expression on adding the index though. But surely will try it tomorrow morning to see if it works.

addProperty(variables(‘Test Scores’)[item()],’Index’,item())

Udula J
Udula J
3 months ago

I failed to notice that the “From” parameter of the “Select” action, is not the initialized Array variable itself, but rather a Range. This clears my doubt.

By any chance, is your range function something similar to the following?

range(0, length(variables(‘Test Scores’)))

Xavier
Xavier
3 months ago

Love this article as always. By the way, can you show us the Range expression when adding an Index position to an array?

Thanks.

Victor Martinez
Victor Martinez
3 months ago

Amazing article Matt, thanks for sharing this valuable info πŸ™‚

Astatke
Astatke
3 months ago

Thank you so much for sharing these excellent techniques.

Issam
Issam
3 months ago

Love this article, thanks for sharing Mat πŸ™πŸΌπŸ˜Š

Marcin
Marcin
2 months ago

Great article, very useful