web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Change combobox defaul...
Power Apps
Unanswered

Change combobox default selected items based on variables

(0) ShareShare
ReportReport
Posted on by 49

Hi All, 

 

I am working on a requirement to have a different selection in the default items of a Combo box based on variables. I need the variables since the gallery would be sorted differently based on them.
The behavior of the combo box should be as follows:

 

I have a collection which is collected on start of the application:

 

 

ClearCollect(colAllCountries,["Alle","BE","BG","DK","DE","UK","EE","FI","FR","GR","HK","IE","IT","HR","LV","LT","NL","AT","PL","PT","RO","SE","CH","RS","SK","SI","CZ","HU","US","ES"])

 

 

The collection is used in the items property of the combo box.

 

I have the following code OnChange of the combo box:

 

 

ClearCollect( col_SelectedCountiesList, Filter( 'Country selection'.SelectedItems.Value, Value <> "Alle" ) );

 

 

 

- this should gather a collection with all of the selected items, without the "Alle" value. 

 

 

 

If( "Alle" in 'Country selection'.SelectedItems.Value, Set( var_toggle1, true ), Set( var_toggle1, false ) And Set(var_toggle2,true) );

 

 

 

- this should set the variable var_toggle1 to true is "Alle" is selected. If this variable is true the following items should be selected as default colAllCountries (All items from the collection). If "Alle" is removed, this is going to set the var_toggle2 to true and var_toggle1 to false, so the dropdown can be reset. 

 

 

 

If( Not("BE" in 'Country selection'.SelectedItems.Value) Or Not("BG" in 'Country selection'.SelectedItems.Value) Or Not("DK" in 'Country selection'.SelectedItems.Value) Or Not("DE" in 'Country selection'.SelectedItems.Value) Or Not("UK" in 'Country selection'.SelectedItems.Value) Or Not("EE" in 'Country selection'.SelectedItems.Value) Or Not("FI" in 'Country selection'.SelectedItems.Value) Or Not("FR" in 'Country selection'.SelectedItems.Value) Or Not("GR" in 'Country selection'.SelectedItems.Value) Or Not("HK" in 'Country selection'.SelectedItems.Value) Or Not("IE" in 'Country selection'.SelectedItems.Value) Or Not("IT" in 'Country selection'.SelectedItems.Value) Or Not("HR" in 'Country selection'.SelectedItems.Value) Or Not("LV" in 'Country selection'.SelectedItems.Value) Or Not("LT" in 'Country selection'.SelectedItems.Value) Or Not("NL" in 'Country selection'.SelectedItems.Value) Or Not("AT" in 'Country selection'.SelectedItems.Value) Or Not("PL" in 'Country selection'.SelectedItems.Value) Or Not("PT" in 'Country selection'.SelectedItems.Value) Or Not("RO" in 'Country selection'.SelectedItems.Value) Or Not("SE" in 'Country selection'.SelectedItems.Value) Or Not("CH" in 'Country selection'.SelectedItems.Value) Or Not("RS" in 'Country selection'.SelectedItems.Value) Or Not("SK" in 'Country selection'.SelectedItems.Value) Or Not("SI" in 'Country selection'.SelectedItems.Value) Or Not("CZ" in 'Country selection'.SelectedItems.Value) Or Not("HU" in 'Country selection'.SelectedItems.Value) Or Not("US" in 'Country selection'.SelectedItems.Value) Or Not("ES" in 'Country selection'.SelectedItems.Value), Set( var_toggle1, false ) And Set( var_toggle3, true ))

 

 

 

- if some of the items are unchecked from the dropdown, this should set the var_toggle1 to false and set var_toggle 3 to true and change the default selected items to the following collection (col_SelectedCountiesList - only the selected values in the dropdown).

 

I have the following code for the DefaultSelectedItems of the combo box:

 

 

If(var_toggle1=true, colAllCountries,If(var_toggle3,col_SelectedCountiesList,If(var_toggle2,Blank())))

 

 

 

The behavior of the dropdown should be:

1. If you select the option "Alle", this should select all the items in the combobox 
2. If you uncheck the option "Alle", this should reset the combo box and remove all the selections and leave the combo box empty.
3. If you select "Alle" and uncheck any of the selected options, for example "BE" or "AT", this should remove "Alle" and leave only the selected items in the combo box.

 

Until now I have been able to make the following: If I select "Alle" from the dropdown menu, all countries are selected. If I uncheck "Alle", the var_toggle2 (which should reset the dropdown) is not set to true, instead var_toggle3 is set to true and only the selected items are displayed. 

 

I am looking for a solution where I can combine point 1, 2 and 3 in one logic so when "Alle" is selected, to select all of the values in the collection as default. If "Alle" is unchecked, to reset the combo box and if "Alle" is selected, but some of the other values are unchecked, to set the default items of the combo box to the collection made OnChange of the control. 

 

Thank you!

Categories:

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 190 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard