Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Suggested answer

Add a blank item to a collection that is filtered in an if statement.

(0) ShareShare
ReportReport
Posted on by 112
Hello
 
I know there are normally several ways to tackle a problem, but this one has me mulling over what to do.  I am hoping to ask your opinion/help.
 
I have a screen with two dropdowns.  The value of these filter the items on a gallery below them.
 
The first dropdown defines what the second one shows.  I am using a collection(s) to provide the items.  
 
Collections;
ClearCollect(colLocationGroup,{Value:"All Locations"});
Collect(colLocationGroup,Sort(Distinct(Filter('PS - Lookups','Choice Type' = "Location"),'Location Group'),Value,SortOrder.Ascending));
RemoveIf(colLocationGroup,Value = Blank());
 
ClearCollect(colLocations,{Title:"All Locations"});
Collect(colLocations,ShowColumns(Filter('PS - Lookups','Choice Type' = "Location"),'Name (Title)','Location Group'));
 
 
First Drop Down Items: (DropDown1)
colLocationGroup
 
 
Second Drop Down Items: 
If(Dropdown1.Selected.Value = "All Locations",
    colLocations,
    Filter(colLocations,field_2=Dropdown1.Selected.Value)
)
 
I want to add an item "All Locations" to that shown in DropDown2.  The specific part I want to change is Filter(colLocations,field_2=Dropdown1.Selected.Value) - ie the best way to add "All Locations" item.
 
Any Ideas?
 
Thanks
 
Stuart
 
Categories:
  • Stuart74 Profile Picture
    112 on at
    Add a blank item to a collection that is filtered in an if statement.
    Brilliant, thank you.  I've not used Table much, so ill explore that more now.
     
    My final code for items on the second drop down.
     
    If(Dropdown1.Selected.Value = "All Locations",
        colLocations,
       
       Table({Title: "All Locations"}, Filter(colLocations,field_2=Dropdown1.Selected.Value))
     
    )
  • Stuart74 Profile Picture
    112 on at
    Add a blank item to a collection that is filtered in an if statement.
    Hello
     
    Apologies, I think I have not been accurate in my ask.
     
    Some data
     
     
     
    So if DropDown1 = "US" then the existing code will mean DropDown2 = Atlanta, Cheasapeake.
     
    What I want to do is add an "All Locations" item to Dropdown2 once Dropdown1 is not All Locations.
  • Suggested answer
    Pstork1 Profile Picture
    67,060 Most Valuable Professional on at
    Add a blank item to a collection that is filtered in an if statement.
    The easiest way to do this is to use the Table() function in the Items property of the Dropdown.  Something like this
     
    Table({Title: "All Locations", <<other fields in collection>>}, colLocations)
  • Suggested answer
    LessCodePaths Profile Picture
    100 on at
    Add a blank item to a collection that is filtered in an if statement.
    Hi,
     
    I guess, it should work the way it is.
    Maybe you can use:
    Filter(
        colLocations,
        Or(field_2=Dropdown1.Selected.Value, IsBlank(Dropdown1.Selected.Value))
    )
    L.

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

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!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1