cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Motty_25
Helper I
Helper I

Default Blank Combobox to all

Hi,

Does anybody know how I can get a Combo Box to default to all if nothing is selected?

At the moment, I have had to set the DefaultSelectedItems to be all values, as if I leave it blank, the search fails.

This means that if there are particular values that people don't want to search for, they have to deselect them.

I would rather, if possible, have people select the values they want to filter by, and be able to leave it blank if they want to search for everything.

Would greatly appreciate any help. 🙂

Many thanks

14 REPLIES 14
RandyHayes
Super User
Super User

@Motty_25 

You can account for this in your formula by looking to see how many items are selected - if none, then assume all, if some, then filter on just those items.

CountRows(yourCombobox.SelectedItems) will return 0 if nothing is selected and you can use that to base your logic on.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @RandyHayes 

Thanks for your response.

Where exactly would this command go? Would this be part of my formula for the filter gallery? (the one which loads when people select the options from the combo boxes and click search) Or would it be part of the properties for each ComboBox?

RandyHayes
Super User
Super User

@Motty_25 

Yes it would be part of the Items property.  What is your formula for that? 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Motty_25
Helper I
Helper I

@RandyHayes 
The formula for each ComboBox is currently
Choices(ListName.FieldName)

 

The formula for my filter gallery is:
Filter(ListName, FieldName1 in ComboBox2.SelectedItems, FieldName2 in ComboBox2_2.SelectedItems, FieldName3 in ComboBox2_1.SelectedItems, FieldName4 in ComboBox2_3.SelectedItems)

(yes, I know I should have named my ComboBoxes properly instead of just keeping the default name after copying them!)

RandyHayes
Super User
Super User

@Motty_25 

If you have all four comboboxes that you want to apply this logic to, then your formula will be:

Filter(ListName, 
    (CountRows(ComboBox2.SelectedItems)= 0 || FieldName1 in ComboBox2.SelectedItems) &&
    (CountRows(ComboBox2_2.SelectedItems) = 0 || FieldName2 in ComboBox2_2.SelectedItems) &&
    (CountRows(ComboBox2_1.SelectedItems) = 0 || FieldName3 in ComboBox2_1.SelectedItems) &&
    (CountRows(ComboBox2_3.SelectedItems) = 0 || FieldName4 in ComboBox2_3.SelectedItems)
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Motty_25
Helper I
Helper I

@RandyHayes 

Thank you, that's worked! Although I now have another issue.

I've currently got the DefaultSelectedItems for each of these ComboBoxes to be all options for that particular field.
If I clear this setting so nothing is selected by default, then when I select the values I want, the search fails.

Motty_25
Helper I
Helper I

Hi all,

Sorry to bump this, but was just wondering if anybody could advise on this?

The issue I now have, is that if I manually deselect the options on the ComboBox, the search works fine, but if I change the DefaultSelectedItems to none, the search fails.

Does anybody know why this might be?

RandyHayes
Super User
Super User

@Motty_25 

Sorry to lose track of your post.  Just seeing it now.

 

So tell me more about this scenario.  What are the Items properties and the DefaultSelectedItems property formulas?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

So, my list name is Register and I have four fields called Asset Type, Status, Location and Model, each of which has a ComboBox associated.

For each ComboBox, both the Items and DefaultSelectedItems properties are "Choices(Register.FieldName)" - e.g. "Choices(Register. 'Asset Type), "Choices(Register.Status)" and so on.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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