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 / Add a blank item to a ...
Power Apps
Suggested Answer

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

(0) ShareShare
ReportReport
Posted on by 116
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:
I have the same question (0)
  • Suggested answer
    LessCodePaths Profile Picture
    100 on at
    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.
  • Suggested answer
    Pstork1 Profile Picture
    68,707 Most Valuable Professional on at
    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)
  • Stuart74 Profile Picture
    116 on at
    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.
  • Stuart74 Profile Picture
    116 on at
    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))
     
    )

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard