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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Filtering an array on ...
Power Automate
Answered

Filtering an array on contains "X" or "Y"

(0) ShareShare
ReportReport
Posted on by 103
Hello,
 
I'm wanting to filter an array of values based on whether a field in the array contains either "HPO" or "GPO"
 
This is my flow and the error I get when just trying to filter on contains HPO
 
 
I'm taking the body of the previous step as my data to filter and then attempting to add another filter, but I get this error
 
Action 'Filter_PO_Number_Exists' failed: The execution of template action 'Filter_PO_Number_Exists' failed: The evaluation of 'query' action 'where' expression '@contains(item()?['Pending Supplier Invoices[PO Number]'],'HPO')' failed: 'The template language function 'contains' expects its first argument 'collection' to be a dictionary (object), an array or a string. The provided value is of type 'Null'.'.
 
Any help would be appreciated.
 
Thanks,
Michael
Categories:
I have the same question (0)
  • Tomac Profile Picture
    4,048 Moderator on at
     
    Looks like your issue is with the value in item()?['Pending Supplier Invoices[PO Number]'] not existing. It really looks like this is a malformed array pointer.
     
    Did you perhaps mean item()?['Pending Supplier Invoices']?['PO Number']
     
    What expression are you using in the previous Filter Array action, which is looking for a similar field?
  • MBates237 Profile Picture
    103 on at
    @Tomac The previous step is this
     
     
    And this gives me 38 records, which is what I'm expecting
     
  • Ellis Karim Profile Picture
    12,024 Super User 2026 Season 1 on at
     
    Perhaps check for a null value first, before using the contains() function. contains() will error if it receives a null value.
     
    Something like:

    @and(
        not(equals(item()?['Pending Supplier Invoices']?['PO Number'], null)),
        contains(item()?['Pending Supplier Invoices']?['PO Number'], 'HPO')
        )
     
    Use "advanced mode" to enter the expression:
     
     
     
    Ellis Karim
    Ellis Karim
    elliskarim.com  |  LinkedIn  |  Bluesky
    If this solved your issue, please mark it as ✅ Accepted Answer. If it helped, feel free to give it a 🩷 Like!
  • Verified answer
    MBates237 Profile Picture
    103 on at
    Thanks for the input both, I had success using the following expression
     
    empty(item()?['Pending Supplier Invoices[PO Number]']) and evaluating that as is equal to false
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 552

#2
Valantis Profile Picture

Valantis 388

#3
11manish Profile Picture

11manish 375

Last 30 days Overall leaderboard