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 Apps / Filter for multiple co...
Power Apps
Answered

Filter for multiple combobox selections in one string

(0) ShareShare
ReportReport
Posted on by 61

Hey everyone,

 

I have the following scenario:
-A combobox with the option for multiple selections enabled. It contains names, but it's not a proper people picker

-A gallery where one item is a string in the form of "Name 1, Name 2, Name 3,  Name 4...)

 

I need to filter my gallery in a way, that every selected item in the combobox is a part of that string.

If I only select one, I can simply use "cmb_Team.Selected.Name in ThisItem.Team" and it works. How could I manage to make it work with multiple names?

 

I was thinking of using ForAll, but couldn't make it work.

Any help would be greatly appreciated.

Categories:
I have the same question (0)
  • madlad Profile Picture
    2,637 Moderator on at

    The ForAll is a good idea. You can use it to check whether each item is in the string, then check whether any of those returns false. 

     

    Maybe try something like:

     

    IsEmpty(
     Filter(
     ForAll(
     cmb_Team.SelectedItems,
     {IsValid: ThisRecord.Name in ThisItem.Team}
     ),
     IsValid
     )
    )

    This will return a true/false value

     

    Hope this helps!

     

  • Dioz Profile Picture
    61 on at

    That sounds like a creative idea, but I couldn't make it work so far.

    I only want the filter to apply when something in the combobox is selected, otherwise it should show all. There are additional filters too, but I tried it like this:

    If(
     !IsBlank(cmb_Team.Selected.Name),
     If(
     IsEmpty(
     Filter(
     ForAll(
     cmb_Team.SelectedItems,
     {IsValid: ThisItem.Name in ThisItem.Team}
     ),
     IsValid
     )
     ) = false,
     true,
     false
     ),
     true)

     

  • Dioz Profile Picture
    61 on at

    I played around a little more and I think my mistake is that in 

    {IsValid: ThisItem.Name in ThisItem.Team}

    ThisItem.Team refers to the datasource of my Combobox, I just didn't notice because that column exists in both datasources, which aren't the same. Simply changing it to colSampleName.Team doesn't do the trick though. I'm not quite sure what could work for me in this case. 

  • Verified answer
    madlad Profile Picture
    2,637 Moderator on at

    If you're using it in a filter statement, and you have multiple datasources, try using an As operator to differentiate. 

    In the code block you sent, you compare ThisItem.Name and ThisItem.Team - this is comparing one item's 'Name' and 'Team' fields. If you're doing it in a filter function, maybe do something along the lines of:

    Filter(
     *DataSource* As GalData,
     IsEmpty(
     Filter(
     ForAll(
     cmb_Team.SelectedItems As ComboItems,
     {IsValid: ComboItems.Name in GalData.Team}
     ),
     !IsValid
     )
     )
    )

     

  • Dioz Profile Picture
    61 on at

    Perfect, that works! Didn't think about using "As" for cases like this in the past, that will come in very handy in other situations too. Thank you so much

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard