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 M...
Power Automate
Unanswered

Filter an Array with Multiple Condition that are Dynamic Values

(0) ShareShare
ReportReport
Posted on by 13

Good afternoon all,

 

I am trying to build a flow that pulls the flattened organisation structure from a PowerBI report and I want to find the first row that a person (from a dynamic value) appears in as that can then be used in further PowerBI queries. I have extracted the data from the BI dataset and have it in an array, but I'm having trouble then filtering it out to get the first time that the person appears. The filter array function lets you have multiple conditions, and dynamic values, but seemingly not both at the same time.

 

Any help would be appreciated. 

 

Trent92_0-1694584227011.png

Trent92_1-1694584241185.png

Trent92_2-1694584254298.png

Trent92_3-1694584273088.png

With my filter function being:

@Anonymous(

contains('ManagerHierarchy[Level 1]', items('Apply_to_each')?['Title']),

contains('ManagerHierarchy[Level 2]', items('Apply_to_each')?['Title']),

contains('ManagerHierarchy[Level 3]', items('Apply_to_each')?['Title']),

contains('ManagerHierarchy[Level 4]', items('Apply_to_each')?['Title']),

contains('ManagerHierarchy[Level 5]', items('Apply_to_each')?['Title']),

contains('ManagerHierarchy[Level 6]', items('Apply_to_each')?['Title']),

contains('ManagerHierarchy[Level 7]', items('Apply_to_each')?['Title']),

contains('ManagerHierarchy[Level 8]', items('Apply_to_each')?['Title'])

)

 

All I receive is a blank array despite being able to search for the two Managers names in the inputs section.

Trent92_5-1694584975326.png

 

 

Categories:
I have the same question (0)
  • Ellis Karim Profile Picture
    11,681 Super User 2025 Season 2 on at

    Hi @Trent92 ,

     

    Looking at your sample data:

    ekarim2020_1-1694587404251.png

     

    Can you try the following format in your filter query:

    contains(item()?['ManagerHierarchy[Level 1]'], items('Apply_to_each')?['Title']),
    contains(item()?['ManagerHierarchy[Level 2]'], items('Apply_to_each')?['Title']),
    ...

     

    See:


    Ellis
    ____________________________________
    If I have answered your question, please mark the post as ☑️ Solved.
    If you like my response, please give it a Thumbs Up.
    My Blog Site

     

  • Trent92 Profile Picture
    13 on at

    That has resulted in an error:

    Trent92_0-1694588268449.png

     

  • Verified answer
    Ellis Karim Profile Picture
    11,681 Super User 2025 Season 2 on at

    Hi @Trent92 ,

     

    OK, I see what is happening here. For the contains() function to work  your data must include all the ManagerHierarchy levels, they cannot be empty or missing. And this is what is causing the error.

     

    The following format would likely work:

     

     

    [
     {
     "ManagerHierarchy[Level1]": "Demo123",
     "ManagerHierarchy[Level2]": "#",
     "ManagerHierarchy[Level3]": "#",
     "ManagerHierarchy[Level4]": "#"
     },
     {
     "ManagerHierarchy[Level1]": "Demo 32",
     "ManagerHierarchy[Level2]": "SDS2",
     "ManagerHierarchy[Level3]": "#",
     "ManagerHierarchy[Level4]": "#"
     },
     {
     "ManagerHierarchy[Level1]": "Demo 1",
     "ManagerHierarchy[Level2]": "SDS2",
     "ManagerHierarchy[Level3]": "demo 4",
     "ManagerHierarchy[Level4]": "demo 5"
     }
    ]
    ]

     

     

    Or do you have a way concatenate all the Manager Hierarchy into a single strings?

     

     

    [ 
    {
     "ManagerHierarchy[Level1]": "Demo123",
     "ManagerHierarchy[Level2]": "ABC",
     "ManagerHierarchy[Level3]": "12345",
     "ManagerHierarchy[Level4]": "zxcxc"
     },
    {
     "ManagerHierarchy[Level1]": "Demo123"
    }
    ]
    
    to
    
    [
     { "ManagerHierarchy": "Demo123, ABC, 12345, zxcxc"},
     { "ManagerHierarchy": "Demo123"}
    ]
    

     

     

    That way you may be able to use a single contains action: contains( item()?['ManagerHierarchy]), items('Apply_to_each')?['Title'])

     


    Ellis
    ____________________________________
    If I have answered your question, please mark the post as ☑️ Solved.
    If you like my response, please give it a Thumbs Up.
    My Blog Site

     

  • Trent92 Profile Picture
    13 on at

    I concatenated the array and it now filters properly.

     

    Thank you for the help!

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 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard