Categories: Microsoft Flow

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.

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.

Microsoft Flow 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.

Share
Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

View Comments

  • 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.

  • 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

  • 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.

  • 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.

    • 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.

Recent Posts

Get started with adaptive cards in Power Automate

Getting started with adaptive cards can be difficult. In this post i have written some…

6 days ago

Create PDF documents from data in Power Automate

In this post I will look at how to create PDF documents from data. Use…

7 days ago

Unnest nested arrays in Power Automate

We all know this problem, you have a nested array in Power Automate but how…

2 weeks ago

Advanced settings not loading in Power Platform

Yesterday one of my clients showed me an issues where the Advanced settings didn't load.…

3 weeks ago

1 Better way to use Create Item in SharePoint with Power Automate

Have you been using the REST API instead of the create item action in Power…

3 weeks ago

Filter by Content Type using Get Items in Power Automate.

In a comment on my Filter Query on Get Items in the SharePoint connector post…

3 weeks ago
%%footer%%