cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dlprentice
Responsive Resident
Responsive Resident

How can I add an "All" option to a dropdown?

I've got a data table, and a few dropdowns that let me filter this data table. I'll like to be able to have an "All" option on each of the 3 dropdowns in question to let the end user broaden their search. Is this possible given the code snippets below?

 

Side note: If StateDropdown is set to "All" CityDropdown would need to be forced to set to "All". Once you view the code snippets you will see CityDropdown is dependent on the state selected in the StateDropdown.

 

Data Table (Items):

Filter (
    AddColumns(
        'ESN Ticket Tracker',
        "City",
        LookUp(
            'Networking Device List Master',
            'DNS Entity Name' = 'ESN Ticket Tracker'[@'Service ID'],
            City
        ),
        "State",
        LookUp(
            'Networking Device List Master',
            'DNS Entity Name' = 'ESN Ticket Tracker'[@'Service ID'],
            State
        )
    ),
    Status = StatusDropdown.SelectedText.Value,
    State = StateDropdown.SelectedText.Value,
    City = CityDropdown.SelectedText.Value
)

StatusDropdown (Items)

Sort(Distinct('ESN Ticket Tracker',Status),Result)

StateDropdown (Items)

Sort(Distinct('Networking Device List Master', State),Result)

CityDropdown (Items)

Sort(Distinct(Filter('Networking Device List Master', State=StateDropdown.SelectedText.Value),City),Result)

Screenshot 2021-02-04 072010.png

Screenshot 2021-02-04 072452.png

11 REPLIES 11

You don't want them nested.   The causes the City formula to only be true if the State formula is true.   



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
JR-BejeweledOne
Super User
Super User

Nesting If statements doesn't always work the way we think it would in Power Apps.    It evaluates each statement until it meets a true condition.   So one of the state conditions is going to be true and it won't even evaluate the If for the city.

 

You have them as separate statements here:

 

State = StateDropdown.SelectedText.Value,
    City = CityDropdown.SelectedText.Value

 

Just add to those like this:

 

If(
AllStates.Value = false,
State = StateDropdown.SelectedText.Value,
State = State,

),

If(
AllCities.Value = false,
City = CityDropdown.SelectedText.Value,
City = City
)

 

)



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,286)