Collection Functions In Microsoft Power Automate

by | Power BI

Power Automate also offers functions that we can use on arrays. These are commonly known as collection functions. In this tutorial, we’ll discuss the different available collection functions in Power Automate and their usage.

An array is a list or collection of elements. It can be a list of strings, integers, and many other collections.

We can do certain things with collections. Here are some functions that we can use when working with arrays.

Collection Functions

Array functions aren’t really used a lot in workflows, but they could definitely be useful, especially for certain conditions. For example, one thing that we can do in an array is to check if it contains a specific item. So let’s see how that works.

Collection Functions In Power Automate: Contains

This function requires a collection or an array and a specific value. It’ll return a Boolean value (true or false) that’s based on whether the specified value is in the specified array. 

Collection Functions

Let’s use that in this sample flow and see how it works. First, delete the Apply to each step because we don’t need it anymore.

Collection Functions

We need a new step based on a condition. So, let’s add a new step.  

Collection Functions

Then, click Control

Collection Functions

Click the Condition control.

Collection Functions

Click the ellipsis for the Condition step then choose Rename.

Collection Functions

Let’s rename this to “Check if any of the words in Input 4 contains the word problem”.

Collection Functions

Let’s now create an array from Input 4. Under the Expression tab, let’s click the split function. 

Collection Functions

Then, click Input 4 under the Dynamic content tab.

Collection Functions

Add a comma and space for it to become an array of words. 

Collection Functions

The next thing that we need to do is to use a collection function under the Expression tab. For this one, click the contains function.  

Collection Functions

Let’s remove the closing parameter ‘)’ of the contains function. 

Collection Functions

We need to check if this array contains the word “problem”. So, let’s add a comma along with the word “problem” and the closing parameter ‘)’ of the expression. 

Collection Functions

Then click the OK button. 

On our condition, we should check if it’s equal to true

After that, let’s add a new action. 

Search and click Slack

Click Post message.

We’ll post this on the general channel. 

Set the message to “Input 4 contains the word problem”.

If the condition is false, nothing will happen. Therefore, let’s leave it blank for now. 

Testing The Flow

Let’s now test this flow. 

Select the “I’ll perform the trigger action” option and click the Save & Test button. 

Other inputs don’t really matter so let’s just put anything on them. For Input 4, let’s type “Power Automate has a huge problem in it! Oh no”. Then, click the Run flow button.

Lastly, click Done

As we can see, our flow ran successfully. 

If we go to our Slack, under the general channel, we can see that it posted a message saying “Input 4 contains a word problem” which means that our flow worked properly. 

Again, by using the contains expression, it checked the words that we’ve entered on the Input 4 field and looked for the word “problem”. It found one so it turned this condition to true, and that’s why our condition went to the if yes pathway. 

***** Related Links *****
Power Automate Split Function And Arrays
Power Automate Apply To Each Action In Workflows
Microsoft Flow Approval With Multiple Options

Conclusion

To wrap up, the contains function is just one of the many functions that we can use for arrays. You can find the full list of all the collection functions within the Power Automate documentation. Some of these aren’t widely used, but you may certainly use these on your flows if you wish to do so.

All the best,

Henry

Related Posts

Comprehensive Data Analysis using Power BI and DAX

Data Model Discovery Library

An interactive web-based application to explore and understand various data model examples across multiple industries and business functions.