Recently a few times I’ve been asked about how to make controls visible or invisible depending on the value selected in dropdowns, combo boxes and various other controls. In this post I’m going through the most common controls used for this.
Controls
Table of Contents
Power Apps has many controls available to help you develop your apps. Quite often when you develop apps that need to contain forms you will need fields to appear or disappear depending on the values selected in fro example a dropdown.
For most controls we have the Visible property that controls the visibility of that control

But how do we check the values of dropdowns, combo boxes, toggles, checkboxes and radio buttons?
Classic Dropdowns
When we have a dropdown and we want to make a text only visible when a specific value has been selected. Then we can set the Visible property to any of the following options. Where I have a Dropdown with just a Value property. If however you have records in your Dropdown then any property can be selected here instead of Value.
Dropdown1.SelectedText.Value = "Yes"OrDropdown1.Selected.Value = "Yes"OrDropdown1.SelectedText.Value = "1"OrDropdown1.Selected.Value = 1
Important to note here that if you make use of the SelectedText property that we always have a Text value even if the item in the dropdown are numbers.

Classic Combobox
Comboboxes are slightly more complicated than Dropdowns. The main complexity is around the setting to sllow multiple selections or not.

If we first assume that Allow multiple selections has ben enabled then the Combobox’s Selected property hold the item record that was selected most recently.

However, most likely using the SelectedItems will give you the result that you are looking for.

If we now disallow multiple selections, then we will find that both options will work and therefore the much simpler option of Combobox1.Selected will have the preference.
Or alternatively you can go for this contruction:
CountRows(Filter(ComboboxCanvas1.SelectedItems, Value = "Item 2")) = 1
Classic Radio Button
For Classic Radio Button we can use the Selected.Value or SelectedText again.
Radio1.Selected.Value = 2or Radio1.SelectedText.Value = "2"

Classic Checkboxes
Checkboxes are very different. A checkbox has a Boolean value telling you if the checkbox has been checked or not.

This means that if you had multiple check boxes ( trying to mimic a multi select radio button then you would have to check multiple checkboxes for their value as shown below:
Or(Checkbox1.Value, Checkbox2.Value)
Classic Toggle
Classix Toggles are a bit like the checkboxes. We can simply look at the Value property.

Modern Dropdown
If we now have a look at the Modern Dropdown

Using the Selected property you can find the selected option as follows.

Alternatively, you could also use SelectedItems however as there is now multiselect option available in Modern Dropdown there is no real benefit for doing this.
First(DropdownCanvas1.SelectedItems).Value = "Item 1"
Modern Combobox
Like with the classic Combobox the Selected.Value will hold the most recently selected item. So this will work in both cases where we allow or disallow the multi select, however When you have a multiselect you most likely will want to user the SelectedItems

Using the SelectedItems with this expression is preferred for multiselect Comboboxes
CountRows(Filter(ComboboxCanvas1.SelectedItems, Value = "Item 2")) = 1
Modern Radio buttons
For Modern Radio button’s we once again have selected and SelectedItems available. As Radio buttons are always single select there is no real need to use SelectedItems.

Modern Check boxes
Unlike Classic Checkboxes, modern checkboxes have a property Checked. The Checked property is a Boolean that tells you if the checkbox has been checked or not.

Modern Toggle
For the modern toggles we have like the check boxes a Checked property. This property tells us if the Toggle has been switched on (true) or off (false).

Classic vs Modern Controls
As you can see from the many examples in this post the behaviour of the various controls isn’t consistent. And quite a few controls use the SelectedItems property even if there is no multiselect available. This all may lead to bugs that are hard to find. Understanding the nuances between the various options is important if you want to create robust apps.
Discover more from SharePains
Subscribe to get the latest posts sent to your email.