cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JR-BejeweledOne
Super User
Super User

Default Selected Items for Combobox

I have a cascading setup where there is a dropdown with a list of countries and a multi-select combobox with a list of associated regions.   There is also a checkbox that allows all regions to be selected.

 

When an item is selected to be edited from the gallery, the regions combobox is populated with the selected regions in the gallery item.   

 

I am trying to add having the checkbox selected if all the regions are present in the gallery item and if it is unchecked have the regions in the multi-select combobox clear out.

 

Regions Combobox defaultselecteditems formula:

Filter(
    Filter(Regions, crc39_Country_1.crc39_name in ComboBoxCountry.Selected.crc39_name && Use = "Yes"
    ),
      EditItem && ( crc39_name in varRecord.Region) || CheckboxAllRegions.Checked
   )

 

Checkbox formula:

If( CountRows(Filter(Regions, Country.Name = ComboBoxCountry.Selected.Name && Use = "Yes")) = CountA(Split(varRecord.Region,";"))-1, true, false)

 

When EditItem is true and a gallery item is selected that contains all the available regions, the checkbox is checked as well.   At this point I want the user to be able to uncheck the checkbox and clear the selected regions from the regions combobox. 

 

 



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.
1 REPLY 1
WarrenBelz
Super User
Super User

@JR-BejeweledOne ,

Firstly if your Combo Box is multi-select and you do not want Delegation warnings, you could do this

With(
   {
      wList:
      Filter(
         Regions, 
         Use = "Yes" &&
         EditItem && 
         (
            crc39_name in varRecord.Region || 
            CheckboxAllRegions.Value
         )
      )
   },
   Filter(
      wList,
      crc39_Country_1.crc39_name in ComboBoxCountry.SelectedItems.Name
   )
)

Your Check Box Default could be this (you do not need the true/false)

CountRows(
   Filter(
      Regions, 
      Country.Name in ComboBoxCountry.SelectedItems.Name && 
      Use = "Yes"
   )= 
   CountA(
      Split(
         varRecord.Region,
         ";"
      )
   )-1
)

but if the checkbox is CheckboxAllRegions, you will probably get a Circular reference - so you may not be able to inter-relate them as changing the control will affect its own default.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,111)