web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Filter an array with a...
Power Automate
Answered

Filter an array with an array of values?

(0) ShareShare
ReportReport
Posted on by 4
Hello! I'm working with D365 FO and Power automate. I'm working with two tables/data entities, Purchase Order Headers table and Purchase Order Lines Table. I'm applying an odata filter to the Headers tables which is being pulled in using the Fin Ops "List items present in table" action. I now want to filter my Lines table based on a field called "PurchaseOrderNumber", which is also present in my Headers table. My Lines table is also being brought in using the same Fin Ops "List items present in table" action.
 
How can I apply a filter to my Lines table that would only show me records based on the results of the filtered Headers table, using the "PurchaseOrderNumber" column? I.e. filter a list of values with an array of values.
Categories:
I have the same question (0)
  • Verified answer
    Mark Nanneman Profile Picture
    991 Super User 2025 Season 2 on at
    If your tables have a relationship, you can use Expand Query and Filter rows (or Fetch Xml) to return only items that belong to certain related tables.

    If there isn't a relationship, one thing you can do is use a Select action to create a simple array that only contains the values you want to filter your other array by.  Then you use a Filter actions that checks if that simple array contains a specific field value in the array you're filtering.

    E.g. Here I'll demonstrate the concept by listing all my Dataverse Contacts, then listing all my Accounts, and filter the Contacts that have a Company ID in the Accounts ID array.
     

    Get both Arrays you want to work with

    here I list Contacts and Accounts

    Create Simple Array of only accountids

    Use select, and toggle to text mode from key/value mode.  Then put in the reference to id column you want to select.


    This creates a simple array of only values with no key:value structure.

    Filter the List Rows - Contacts output array by checking for rows where the "Company (Value)" id is contained by the simple array created above.

    From is the output of the List Rows on the Contacts table.  The first Filter Query parameter is the output of the simple array of Account IDs.  We compare this to the current Contact's Company lookup "item()?['_parentcustomerid_value']" field with a "contains" operator.

     
     

    This filters the Contacts that have a Company ID in the Accounts array.

    Here the filter outputs 147 contacts
    While the original list of contacts had 172



    If this helped you, please click "Does this answer your question" and give it a like to help others in the community (+ close the ticket)!

    Power Platform Developer | LinkedIn: Mark Nanneman | Blog: Power Stuff  | YouTube: Mark's Power Stuff
  • Garrett Profile Picture
    4 on at
    Mark, your answer worked great! Now my final hurdle... how do I turn the fields from the filtered array into dynamic content? It seems I can only pick fields from the "List items" action and not the filtered version. If I can turn this into dynamic content, I'm golden.
     
    Thank you!
    Garrett
     
     
  • Mark Nanneman Profile Picture
    991 Super User 2025 Season 2 on at
    You can use expressions to select any property anywhere, even if they don't show up in the selection tool.

    If you check a run of the flow and look at the outputs of a filter, you'll see something like:

    You can reference the properties (columns) in each item in the array using item()?['property_name'] notation.
     
    Anytime you select a dynamic property from a previous step in the selection tool, if you hover over it or copy and paste it into notepad or the expression editor in power automate, you'll usually see something like:
    @{item()?['fullname']}
    If i wanted to loop through a Filter on a Contacts table and reference it item's 'Full Name' property, but it doesn't show up in your selection tool, I'd do this:

    Sometimes after you do this, power automate is smart enough to recognize which field you're referencing from what original data source (even if you're directly referencing the output of a filter), and will show you the actual label of the property:



    When it runs, it grabs the property.






     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard