Select the item based on a key value using Filter Array in Power Automate

In case you need to select an item from an array in Power Automate based on the value of a certain attribute, here’s how you can do it.


In the below example, we want to select the item / array of objects where we want to select based on a value of an attribute. Here, the attribute is “key” and we want to select the condition to match the value “RelatedEntities

As you see, the array of objects have different structure – All of them have an attribute called “key” and that’s the one you want to select and then process further.

Let’s see how we do it.

Filter Array

Let’s see how you can select the item from the array based on the value of the “key” attribute instead of looping through all the items and matching.

  1. Now, let’s say the data is stored in the variable for demo purposes, that’s what I’m feeding into the Filter Array action in the Flow.
    Remember what goes into the Filter Array action has to be an array data.

  2. In Data Operations connector, you’ll find the Filter Array action which we’ll need to pick the item with “key” = “RelatedEntities”

  3. In Filter Array, you set the Input to the array data which is stored in the variable shown above.

  4. Once you select, you then need to provide the condition to filter the Array.
    In this example, we want to filter based on the “key” = “RelatedEntities” as seen in the Scenario section above.
    So, in the dynamic content section, go to Expression section and then use item() function and just like you access an element in a JS, you can mention what attribute you are trying to access.

  5. And in the value, you can mention what the value has to be.

  6. And in the answer, when you run the Flow with the sample data, you’ll get the below result.

  7. The other elements are filtered out. If you have two items of the same value, both will be returned.

  8. Below is how the actual code looks like when you edit in Advanced Mode –

Hope this was useful!

Here are some Power Automate posts you want to check out –

  1. Blocking Attachment Extensions in Dynamics 365 CRM
  2. Upgrade Dataverse for Teams Environment to Dataverse Environment
  3. Showing Sandbox or Non Production Apps in Power App mobile app
  4. Create a Power Apps Per User Plan Trial | Dataverse environment
  5. Install On-Premise Gateway from Power Automate or Power Apps | Power Platform
  6. Co-presence in Power Automate | Multiple users working on a Flow
  7. Search Rows (preview) Action in Dataverse connector in a Flow | Power Automate
  8. Suppress Workflow Header Information while sending back HTTP Response in a Flow | Power Automate
  9. Call a Flow from Canvas Power App and get back response | Power Platform\
  10. FetchXML Aggregation in a Flow using CDS (Current Environment) connector | Power Automate
  11. Parsing Outputs of a List Rows action using Parse JSON in a Flow | Common Data Service (CE) connector
  12. Asynchronous HTTP Response from a Flow | Power Automate
  13. Validate JSON Schema for HTTP Request trigger in a Flow and send Response | Power Automate
  14. Converting JSON to XML and XML to JSON in a Flow | Power Automate

Thank you!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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