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 / An array in Filter Query
Power Automate
Unanswered

An array in Filter Query

(0) ShareShare
ReportReport
Posted on by 62

Hi, I want to filter items using an array variable from another list. The query would be something like this: client eq 'a' or client eq 'b' or client eq 'c' ... where list of clients comes from another sharepoint. Any ideas? 

Categories:
I have the same question (0)
  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @kenneth0596 

    You can't use an array in your filter query.  I suggest using a string variable.  Loop through the array and append

    client eq '[current array value here]'  or   

    in each loop.

    In the last loop, don't add the or at the end.

    Substitute the current value in the array from Dynamic properties for [current array value here].

     

    In my example, please note that there is a space after or in the append to string action.

    image.pngimage.pngimage.png

     

  • Swiftx64 Profile Picture
    2 on at

    Hey,

     

    Thank you for sharing this, I am trying to follow along but having an issue.

     

    Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The inputs of template action 'Append_to_string_variable' at line '1 and column '2469' is invalid. Action 'Apply_to_each' must be a parent 'foreach' scope of action 'Append_to_string_variable' to be referenced by 'repeatItems' or 'items' functions.'.'."

     

    What would cause that error?

     

    https://powerusers.microsoft.com/t5/Building-Flows/Action-Apply-to-each-must-be-a-parent-foreach-scope-of-action/m-p/1266735/thread-id/144590

  • lokeshraje Profile Picture
    3 on at

    Thanks a lot for your solution. That worked for me.

  • badri123 Profile Picture
    10 on at

    Yes, you can use an array in your filter query.  you can write a Power FX query
    Like - concat('ID eq ',join(split(triggerBody()['text'],','),' or ID eq '))

    badri123_0-1685108569523.png
    Result ---
    badri123_1-1685108582157.png

     

    Thanks!

  • VictorIvanidze Profile Picture
    13,073 on at

    Hi @badri123,

    you are talking about creating a string, not about creating an array. 

  • badri123 Profile Picture
    10 on at

    hello @VictorIvanidze,
    You can implement both array and string. If you are working with string, you can use the split function. However, if you are not dealing with string, you can use array without the split function.

    Please follow below example - 
    String
    concat('client  eq ',join(split(triggerBody()['text'],','),' or client  eq '))

    Array

    concat('client  eq ',join(variables('varArray'),' or client  eq '))



    badri123_1-1685200855289.png

     

    badri123_0-1685200820157.png


    Thnkas

     

  • CU07080701-0 Profile Picture
    on at

    I couldn't get this to work as described above.

     

    The format that worked for my requirement - filtering IDs not in an array - is as follows:

    (ID ne '289') and (ID ne '176') and (ID ne '192') and ...

    i.e. each condition is enclosed in parentheses.

     

    To build this up and because I can never remember how to correctly escape characters, I created compose steps for each weird character:

    msedge_DxYi1zcIj0.png

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Then a final compose step brings them together, which is the same as @badri123's method above :

    concat(outputs('lbr'),'ID ne ',outputs('quote'), join(variables('varArray'), concat(outputs('quote'),outputs('rbr'),' and ',outputs('lbr'),'ID ne ',outputs('quote'))),outputs('quote'),outputs('rbr'))

    The compose output then goes straight into the Odata filter query

    msedge_F8qNlE2SaV.png

     

  • GuillaumeBD Profile Picture
    23 on at

    Hello, I tried your formula but I can't make it work. Here's the info below:

     

    The flow:

     

    GuillaumeBD_0-1717166372957.png

     

    The result of join step:

    GuillaumeBD_1-1717166403421.png

     

    Your formula I changed for my needs in Get Items-Copy:

    GuillaumeBD_3-1717166434874.png

    Error Message:

    GuillaumeBD_2-1717166418438.png

     

    Any ideas why it's not working?

     

    Thank you

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

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard