When you want to filter an array in a Power Automate flow, there are a couple of challenges you might face.
Other array operations
Table of Contents
A while back wrote a post about arrays in Power Automate. One of the things that I didn’t look at was filtering arrays. Filtering arrays is actually really simple.
Power Automate has filter options available to make things easy. Before I filter an array I will first create an array.
Create an array
I started by creating an array. The array starts with [ and it ends with ] and each item inside the array starts with { and ends with }. All standard json stuff.

You could of course also use a compose action instead of this but it doesn’t matter too much.
You might also have an action that generates an array and you haven’t got any option to specify filters on the action and the action returns too much information.
Filter Array or Collection
Now I only want to select the items that have IsOk set to Yes. This can be done with the Filter array action.

The filter array’s condition can be set in the advanced mode to
@equals(item()?['IsOk'], 'Yes')
Or you could set the left hand side of the condition to item()?[‘IsOk’] using the expression editor and then set the right hand side to Yes.
The conditions here could include any kind of query that you would also use in conditions in your flow. So if you want to filter an array in you Power Automate flow, using the Filter action and set your condition.
Power Automate is sometimes just that simple!
Discover more from SharePains
Subscribe to get the latest posts sent to your email.