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 :
Power Apps - Building Power Apps
Answered

Filter Gallery and show ALL items when nothing is selected from dropdown

(0) ShareShare
ReportReport
Posted on by 22

Hi,

 

I know I am missing something silly here.

I have a gallery to display all my items and added a dropdown to filter the gallery.

I am trying to display all items if the dropdown is blank, but I cannot get it to work.

(The first option on my dropdown is Blank(), followed by the rest of my values)

 

 

 

 

Sort(Filter('Aphrodite Tests and Projects', Dropdown1.Selected.Value = Status.Value), Number, Descending)

 

 

 

 
I'm hoping someone can please help me with this. 🙂 

I have the same question (0)
  • JasonLane Profile Picture
    261 on at
    Re: Filter Gallery and show ALL items when nothing is selected from dropdown

    @nicolaasvdw 

    to display all items in a gallery if the dropdown is blank in PowerApps, you can use the If function to check if the Selected value of the dropdown control is blank or not.

    Here is an example formula you can use in the Items property of your gallery control:

    If(IsBlank(Dropdown1.Selected.Value), your_datasource_name_here, Filter(your_datasource_name_here, Field1 = Dropdown1.Selected.Value))

    In this formula, replace "Dropdown1" with the name of your dropdown control, and "your_datasource_name_here" with the name of your data source.

    The formula uses the If function to check if the Selected value of the dropdown control is blank or not. If it is blank, the formula returns the entire data source (i.e., all items). If the Selected value is not blank, the formula uses the Filter function to return only the items where the value in "Field1" (replace with your actual field name) matches the Selected value of the dropdown control.

    Note that if your data source has multiple fields, you may need to adjust the formula to filter on the correct field.

  • Verified answer
    iAm_ManCat Profile Picture
    18,223 Most Valuable Professional on at
    Re: Filter Gallery and show ALL items when nothing is selected from dropdown

    Hey @nicolaasvdw 

     

    You should be able to use the following - you can expand this to any number of fields by following the same formula of checking if the length of the selected value is zero otherwise filter that field by the dropdown value.

    Sort(
     Filter(
     'Aphrodite Tests and Projects',
     //Check if length of selected is zero, else filter by that selection
     Len(Dropdown1.Selected.Value)=0 || Dropdown1.Selected.Value = Status.Value
     ), 
     Number, 
     Descending
    )

     

    So let's say you also have a searchbox where people can type to search, you would then write:

     

    Sort(
     Filter(
     'Aphrodite Tests and Projects',
     //Check if length of selected is zero, else filter by that selection
     Len(Dropdown1.Selected.Value)=0 || Dropdown1.Selected.Value = Status.Value,
     //Check if length of selected is zero, else filter by that text
     Len(TextInputNameHere.Text)=0 || StartsWith(FieldNameHere, TextInputNameHere)
     ), 
     Number, 
     Descending
    )

     

    Cheers,

    Sancho

  • nicolaasvdw Profile Picture
    22 on at
    Re: Filter Gallery and show ALL items when nothing is selected from dropdown

    This worked perfectly. Thank you @iAm_ManCat !

  • PrecisionBits Profile Picture
    28 on at
    Re: Filter Gallery and show ALL items when nothing is selected from dropdown

    Hi Sancho, 

     

    Used the || (or) in a filter, search, and sort build I had on a gallery, where the filters were doing in operations off of a collection I'd populate. The solution worked where essentially I did something like this, with four different variations: 

     

    IsEmpty(collectionLocationFilter)||locationName in collectionLocationFilter.locationName

     

    The issue I had historically was that if my collection was empty the entire gallery was blank. So if I am understanding the Or logic here is it IsEmpty=True and the blank collection in statement is false, then it essentially skips the filter clause? Versus IsEmpty = False, and the collection is populated so it is True and filters the collection?

     

    Overall I am happy that it works cause been trying a lot of variations on the build, just fuzzy on how the ||(Or) logic is operating in the filter clause for my future reference. 

  • iAm_ManCat Profile Picture
    18,223 Most Valuable Professional on at
    Re: Filter Gallery and show ALL items when nothing is selected from dropdown

    Heya!

     

    Yeah that's pretty much right - when you combine multiple it can be a bit trickier, and you might need to wrap them in brackets to ensure that the parts of the filter you Do want to work still get done.

     

    I'll give a few examples here based on the line you provided, this one if empty will ignore all other filters:
    (also be careful of using 'in', as its not delegable, so if the item you are looking for is out side of the 2000 item limit, it will only show blanks as it can't find past the initial 2k items)

    Filter(BleepBloop,
     IsEmpty(collectionLocationFilter) || locationName in collectionLocationFilter.locationName
     || IsBlank(testname) || testname = "woozle" || Day() = 7
    )

      

    This one separates the logic blocks using brackets, but still has the same issue that if the first one is empty then none of the other logic will be checked as the whole statement is already defined as 'true':

    Filter(BleepBloop,
     (IsEmpty(collectionLocationFilter) || locationName in collectionLocationFilter.locationName)
     || 
     (IsBlank(testname) || testname = "woozle")
     ||
     (Day() = 7)
    )

     

    But to really separate the logic we need both && and ||

    Filter(BleepBloop,
     //Either option in this condition, if first is true then second is not evaluated
     (IsEmpty(collectionLocationFilter) || locationName in collectionLocationFilter.locationName)
     // AND either of these conditions, if first is true then second is not evaluated
     &&
     (IsBlank(testname) || testname = "woozle")
     // AND, even if the above two condition sets are not met, the below filter must apply
     &&
     (Day() = 7)
    )

     

    If you need any help with the && || logic, start a new topic and tag me into it - I like doing these and/or groups 🙂

    I'm on most days, but sometimes there may be some delays with me responding as work can get busy

  • CG-21101257-0 Profile Picture
    11 on at
    Filter Gallery and show ALL items when nothing is selected from dropdown
    @iAm_ManCat Your solution seems to be achieving exactly what i am after, i just cannot get it to work. 

    I currently have two combo box filters applied to my list gallery, but i can't work out how to show all when nothing is selected. 
     
    Filter(
        'CAPA Database (Sensing BU)',
        'CAPA Action Status'.Value = ComboBox1.Selected.Value && 'CAPA Type'.Value = ComboBox1_1.Selected.Value
    )
     
     
    Also, is there a way to set a specific drop down value as default view when people load the list?

    thank you 
    Callum 

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 829 Most Valuable Professional

#2
developerAJ Profile Picture

developerAJ 570

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 403 Super User 2025 Season 2

Last 30 days Overall leaderboard