cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Antonioclk
Helper III
Helper III

select all if combobox is empty and issue on multiple selection

hello, i have an app with a gallery who shows items based on a searchbar text and a combo selected values. 

 

1) i need that when the app starts, and the combobox is empty, the gallery should show all the items, like it's not filtering. how can i do that?

2) when i select one single value, the filter is correct, but when i select multiple values, it filter only the last item added. why?

this is my code:

sportsList is my combo, Sport  is a choice column of my sharepoint.

Filter(
    Search(
        MyData,
        SearchBar.Text,
        "Username",
        "LocationName",
        "Location2"
    ),
    sportsList.Selected.Value = Sport.Value
)

i figured i had to use SelectedItems.Value for multiple data, but if i use it it gives me an error, because it says it's impossible to compare a table with a text

 

how to fix?

 

thank you so much

1 ACCEPTED SOLUTION

Accepted Solutions
BCBuizer
Super User
Super User

Hi @Antonioclk ,

 

The below should do the trick for what you described: no filtering for Sport if nothing is selected:

 

Filter(
    Search(
        MyData,
        SearchBar.Text,
        "Username",
        "LocationName",
        "Location2"
    ),
    If(
        IsEmpty(sportsList.SelectedItems),
        true,
        Sport in sportsList.SelectedItems
    )
)

 

For aesthetics you can change the IsSearchable and NoSelectionText properties of the sportsList ComboBox to ,respectively, false and "All" to make it look as if all items are selected when none are.

 

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

View solution in original post

6 REPLIES 6
BCBuizer
Super User
Super User

Hi @Antonioclk ,

 

The below should be of help. It uses an If loop to check if there's anything in the SearchBar and only applies the Search() if there is. The second part uses the in operator to check the multiselect. It is not delegable, so depending on your specifics you may want to look for an alternative:

 

Filter(
    If(IsBlank(SearchBar.Text),true,
	Search(
        MyData,
        SearchBar.Text,
        "Username",
        "LocationName",
        "Location2"
    )),
    Sport in sportsList.SelectedItems
)

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

hello, thank you so much!
the Sport in sportsList.SelectedItems works! the other part (if(isblank(xx)) gives me error.

how should it work? why are you checking the blank in the search? maybe i didn't explain myself well.

 

the blank search already shows me all the items. what i'd like to do is that when the app is opened, the combobox is empty, and i would love for it to work as if it had all items selected... is that possible?

 

BCBuizer
Super User
Super User

Hi @Antonioclk ,

 

In that case please remove the IsBlank() part:

 

Filter(
    Search(
    MyData,
    SearchBar.Text,
    "Username",
    "LocationName",
    "Location2"
    ),
    Sport in sportsList.SelectedItems
)

 

To have all items in the sportsList combobox selected, set the DefaultSelectedItems property to match the code for the Items property, probably something like:

 

Choices(MyData.Sport)

  



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

is there a way to start the app with the combobox blank, notshowing anything... but the list filtered as if all items were selected? or to add an item "all" in the combobox and when "all" is selected, it consider all the items? 

I don't like to see the combo so full right when the app is started, but at the same time i want to show all the items

BCBuizer
Super User
Super User

Hi @Antonioclk ,

 

The below should do the trick for what you described: no filtering for Sport if nothing is selected:

 

Filter(
    Search(
        MyData,
        SearchBar.Text,
        "Username",
        "LocationName",
        "Location2"
    ),
    If(
        IsEmpty(sportsList.SelectedItems),
        true,
        Sport in sportsList.SelectedItems
    )
)

 

For aesthetics you can change the IsSearchable and NoSelectionText properties of the sportsList ComboBox to ,respectively, false and "All" to make it look as if all items are selected when none are.

 

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

Great solution! thank you so much

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (2,520)