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

Community site session details

Session Id : QR2F8p8+ZlOFmFKzGVikz2
Power Apps - Building Power Apps
Unanswered

Gallery filter using If function - Items property question

Like (0) ShareShare
ReportReport
Posted on 6 May 2021 14:41:03 by 33

Hi all,

First-time Powerapps user here (and non-dev) - I’m hoping someone can provide guidance to help me resolve a bug in the app I’ve built. Scenario is:

  • I have a page with two galleries: The first is a vertical gallery that lists customers and status (called Pipeline Stage); The second is a list of checkboxes that can filter the vertical gallery.
  • The page also has a search box, which can also filter the vertical gallery

The Items property on the vertical checkbox currently does the following (all desired behavior):

  • Loads all customers upon launch
  • Filters correctly when user checks any of the checkboxes
  • Further filters using the search box

I would also like to ensure that a user can enter text in the search box – without having any checkboxes checked. At present, if I type in the search box w/o any checkboxes selected, the vertical gallery disappears. How should I modify the code in Items to do this correctly? Current code is:

 

 

 

 

If(IsEmpty(FilterByStage.SelectedItems) && IsBlank(txtNameFilter.Text), Table1,

Filter(

Table1, 'Pipeline Stage' in FilterByStage.SelectedItems.Pipeline_x0020_Stage &&

StartsWith(Customer, txtNameFilter.Text)

)

)

 

 

 

 

Note: Changing “&&” to “||” in the Filter function breaks the checkbox functionality.

Any suggestions as to how I can resolve this?

Thanks so much for the guidance…

  • Marcusm Profile Picture
    33 on 06 May 2021 at 21:53:09
    Re: Gallery filter using If function - Items property question

    Thanks so much Randy.  Your suggested code does make the search box work as desired, but there is a regression with the checkbox functionality, and as your comment indicates, I now realize that I probably didn't implement that properly to cover all scenarios.  I've attached an image documenting key settings in my app.  I use the Collect function for the checkboxes, which then is supposed to make selections in a (hidden) combo box.  Per the docs, do I need to use a variable instead of Collect?  if so, what would that look like (since my variable would have to be "whichever checkboxes are selected")?   or is there still a way to use Collect?

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 06 May 2021 at 14:51:19
    Re: Gallery filter using If function - Items property question

    @Marcusm 

    Welcome to PowerApps - no-dev experience required!

     

    You mention checkbox functionality, but I am not seeing where that even is in your formula.

    In general though, your formula should be the following:

    Filter(Table1, 
     (IsBlank(FilterByStage.Selected.Pipeline_x0020_Stage) || 'Pipeline Stage' in FilterByStage.SelectedItems.Pipeline_x0020_Stage) &&
     (IsBlank(txtNameFilter.Text)) || StartsWith(Customer, txtNameFilter.Text)
    )

     

    Try to always avoid If statements in filter functions or Items properties unless absolutely necessary.

     

    I hope this is helpful for 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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2