Create and Filter an array in 2 easy steps

Filter an array or collection in Power Automate

When you want to filter an array in a Power Automate flow, there are a couple of  challenges you might face.

Other array operations

A while back wrote a post about arrays in Flow. 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.

An Array in Power Automate

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.

Filter the Array in Microsoft Flow

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!

12 thoughts on “Filter an array or collection in Power Automate

  1. I’m trying to pull multiple lines of data from an excel spreadsheet into a word template using MS Flow. Would an array work to pull the information.

  2. Can you please help me? I have a string in Logic Apps which is 40 chars long and I need to trucate it to 30. I don’t see a function like that and I have googled for hours. If you have any suggestions please let me know. Thanks! MIke Kiser

  3. Every day you make my day! Thank you very much for your help with Power Automate! It’s a great tool, but sometimes simple tasks become nightmares in Power Automate.

  4. Hi, I’ve used your posts quite a few times, so thanks. My current problem is that I cannot get a Power Automate Filter Array action to work with a Contains operator applied to an array obtained by a Get Items action. The column I’m trying the filter on is a multivalued choice column. Please have you come across any problems doing this?
    Regards, Stan.

    1. Hi Stan,

      Multi select choice fields or multi select people fields can indeed be complicated. You might have to push the records through a Select action and using this action reshape the data a bit to make the filtering easier.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: