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 Apps / Can you Filter() based...
Power Apps
Unanswered

Can you Filter() based on an Array?

(0) ShareShare
ReportReport
Posted on by 23

Is it possible to use the Filter function where you are looking if a value exists with an array of values, for example something like Filter(Table, Value in Array)?

I have an App where a user selects from a dropdown; based on the user selection I lookup a value in a column from a Sharepoint list, the value in itself is a comma delimited string. I've Split the value to create an array and now I need to do another filter/search/lookup to SharePoint to get some text for each of the delimited items. Is this possible or do I need to use ForAll?

To expand with an example:
The dropdown selected by the user returns the text from a SharePoint list such-as: "AB-01, AB-02, AB-05" 
I can split the string using the Split function into an array (or probably more accurately a single column table?)
Now I want to look up the text in a different SharePoint list that is related to AB-01, AB-02, AB-05
So something like Filter the data where column X has a value of AB-01 or AB-02 or AB-05 (but I only know this at runtime)

Thanks in advance

Paul

Categories:
I have the same question (0)
  • PaulD1 Profile Picture
    2,914 on at

    You may be able to use 'in' but it won't be delegable when used that way.

    Below is a snippet of a (very long, hoho - low code?) filter where I am splitting an array 'FilterStatus' which contains a comma separated list of selected statuses the users wishes to see.

    I'm allowing for up to 7 statuses to be selected. There is no status 'X' so if only one status is selected (say, 'Open') the predicate becomes:

    Status = 'Open' Or Status = 'X' Or Status = 'X' Or Status = 'X' Or Status = 'X' Or Status = 'X' Or Status = 'X' Or Status = 'X'

    When constructed this way the filter will delegate.

     

     Status = First(
     Split(
     FilterStatus,
     ","
     )
     ).Result Or Status = Coalesce(
     Last(
     FirstN(
     Split(
     FilterStatus,
     ","
     ),
     2
     )
     ).Result,
     "X"
     ) Or Status = Coalesce(
     Last(
     FirstN(
     Split(
     FilterStatus,
     ","
     ),
     3
     )
     ).Result,
     "X"
     ) Or Status = Coalesce(
     Last(
     FirstN(
     Split(
     FilterStatus,
     ","
     ),
     4
     )
     ).Result,
     "X"
     ) Or Status = Coalesce(
     Last(
     FirstN(
     Split(
     FilterStatus,
     ","
     ),
     5
     )
     ).Result,
     "X"
     ) Or Status = Coalesce(
     Last(
     FirstN(
     Split(
     FilterStatus,
     ","
     ),
     6
     )
     ).Result,
     "X"
     ) Or Status = Coalesce(
     Last(
     FirstN(
     Split(
     FilterStatus,
     ","
     ),
     7
     )
     ).Result,
     "X"
     )
     ),

     

  • brianng2 Profile Picture
    14 on at

    I have spent the whole 2 days for this solution. a little bit hard-coded but that works perfectly! greatly appreciated!

  • charleshu Profile Picture
    4 on at

    @brianng2  how did you solve the problem?

  • brianng2 Profile Picture
    14 on at

    @charleshu : I used the code snippet above, just changed the "Status" by my column's name in my table,  in my case it's ProgramID) and the "FilterStatus" by this.ProgramID. 

     

    In the example, @PaulD1 show 7 values of status, if your application has more or less the status's options, you can delete or add more depend on your needs.

     

    Below is my code snippet for your reference

     

    Filter(ds_ProgramCodes, ProgramID = First(
     Split(
     ThisItem.ProgramID,
     ","
     )
     ).Result Or ProgramID = Coalesce(
     Last(
     FirstN(
     Split(
     ThisItem.ProgramID,
     ","
     ),
     2
     )
     ).Result,
     "X"
     ) Or ProgramID = Coalesce(
     Last(
     FirstN(
     Split(
     ThisItem.ProgramID,
     ","
     ),
     3
     )
     ).Result,
     "X"
     ) Or ProgramID = Coalesce(
     Last(
     FirstN(
     Split(
     ThisItem.ProgramID,
     ","
     ),
     4
     )
     ).Result,
     "X"
     ) Or ProgramID = Coalesce(
     Last(
     FirstN(
     Split(
     ThisItem.ProgramID,
     ","
     ),
     5
     )
     ).Result,
     "X"
     ) Or ProgramID = Coalesce(
     Last(
     FirstN(
     Split(
     ThisItem.ProgramID,
     ","
     ),
     6
     )
     ).Result,
     "X"
     ) Or ProgramID = Coalesce(
     Last(
     FirstN(
     Split(
     ThisItem.ProgramID,
     ","
     ),
     7
     )
     ).Result,
     "X"
     )
     ).ProgramName
  • charleshu Profile Picture
    4 on at

    thanks! @brianng2  I am trying to create a function where users can enter line separated values into a multi-line textbox and the gallery will filter based on the list of values in the textbox. So the list of values can be quite dynamic. I tried using in split functions but it has delegation issues.. 

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 431

#2
WarrenBelz Profile Picture

WarrenBelz 360 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 280 Super User 2026 Season 1

Last 30 days Overall leaderboard