Power Apps Uncheck Checkbox When Another is Checked [With Various Examples]

I built a Travel Request application in Power Apps a few days ago. Within that application, I have two checkboxes to describe flight ticket types: Economy and Business. I was required to build a logic so the user could select any option from the two checkboxes.

In this article, I will explain how to achieve a single selection from multiple checkbox controls in Power Apps.

Power Apps Uncheck Checkbox When Another is Checked

Here, we will discuss the Power Apps uncheck the checkbox when another is checked with a simple example:

Example-1:

In Power Apps, I have added three Checkbox controls, i.e., [chk_Male, chk_Female, and chk_Others]. The remaining checkbox controls will be unchecked whenever the user selects one checkbox value.

Refer to the below screenshot:

PowerApps Uncheck Check box Control When Another is Checked

Also, when the user provides the data in the new Power Apps form and clicks the button control, it will be saved or patched on the respective SharePoint Online list [Employee Registration], as shown below.

PowerApps Uncheck the Checkbox When Another is Checked

To achieve this example, follow the steps below.

1. I have a SharePoint Online list named “Employee Registration,” and this list contains the below

Column NameData Type
First NameIt is a single line of text
Last NameA single line of text
GenderA single line of text
DesignationA single line of text
Uncheck Check box When Another is Checked in Power Apps

Note:

If you want to patch the Power Apps manual form data into the SharePoint list then, you should add only text fileds as I mentioned-above.

2. Now, on the Power Apps app -> Select the App object and set Its OnStart property to the code below.

OnStart = Set(varMale,true);
Set(varFemale, false);
Set(varOthers, false);

Where,

  • Set() = This function is used to set a global variable to the entire app
  • varMale, varFemale, varOthers = Variable Names
PowerApps Uncheck Check box When Another is Checked

3. On the Power Apps Screen -> Insert three Text input controls -> insert three Checkbox controls, and set Its Default and UnCheck properties as shown below.

Default = varMale
UnCheck =  Set(
    varMale,                                                                        //For chk_Male
    true
);
Reset(chk_Female);
Reset(chk_Others)                                                                   

Default = varFemale  
UnCheck = Set(
    varMale,                                                                      //For chk_Female
    false
);
Reset(chk_Male);
Reset(chk_Others)                                                                    

Default = varOthers
UnCheck = Set(
    varMale,                                                                       //For chk_Others
    false
);
Reset(chk_Female);
Reset(chk_Male)                                                                  

Where,

  • chk_Male, chk_Female, chk_Others = Power Apps Checkbox Control Names
  • Reset() = This function is used to reset a control to its Default property value
Power Apps Uncheck Check box When Another One Checked

4. Finally, insert a Button control and set its OnSelect property to the code below.

OnSelect = Patch(
    'Employee Registration',
    Defaults('Employee Registration'),
    {
        Title: TextInput_FirstName.Text,
        'Last Name': TextInput_LastName.Text,
        Designation: TextInput_Designation.Text,
        Gender: If(
            chk_Male.Value,
            "Male",
            chk_Female.Value,
            "Female",
            chk_Others.Value,
            "Others"
        )
    }
)

Where,

  • Patch() = This Patch function allows you to create and modify records in your data source 
  • ‘Employee Registration’ = SharePoint Online List
  • Defaults() = This function uses the Defaults function to pre-populate a data entry form, making filling it easier. 
  • Title, ‘Last Name’, Designation, Gender = SharePoint List Text Fields
  • “Male”, “Female”, “Others” = Checkbox Text Values
PowerApps Uncheck a Checkbox When Another One Checked

5. Once your app is ready, Save, Publish, and Preview the app. When the user provides data in the Power Apps form [Including the checkbox value] and clicks on the button control, it will be saved in the SharePoint Online list like below.

PowerApps Uncheck a Checkbox When Another is Checked

This is how to work with the Power Apps uncheck the checkbox when another is checked.

Example-2:

In Power Apps, there is a Checkbox control inside a Power Apps gallery control. When the user selects any product name from the checkbox control, the remaining checkbox controls will uncheck, as in the screenshot below

Power Apps Uncheck Checkbox When Another is Checked

To achieve it, follow the below steps.

1. I have a SharePoint list Online named “Product Details.” This list contains the below fields.

PowerApps Uncheck Checkbox When Another is Checked

2. Next, on the Power Apps screen -> Insert a Blank flexible gallery control and set its Items property as:

Items = 'Product Details'

Where,

  • ‘Product Details’ = SharePoint Online List
PowerApps Uncheck Checkbox When Another One Checked

3. Then, insert a Checkbox control inside the gallery and set its Text property to the code below.

Text = ThisItem.Title

Where,

  • Title = SharePoint list text field
Power Apps Uncheck Check box When Another is Checked

4. Whenever we add a checkbox control, we can select multiple checkbox values. However, our requirement is that Power Apps uncheck the checkbox when another is checked, as shown below.

Power Apps Uncheck Checkbox Control When Another is Checked

5. To do so, set the Check box’s OnCheckDefault, and DisplayMode properties as shown below.

OnCheck = Set(
    varCheck,                                                                             //OnCheck Property
    gal_EmployeeDepartments.Selected.Title
)

Default = varCheck=ThisItem.Title                              //Default Property

DisplayMode = If(
    varCheck = ThisItem.Title,                                           //DisplayMode Property
    DisplayMode.View,
    DisplayMode.Edit
)

Where,

  • varCheck = Power Apps Variable Name
  • gal_EmployeeDepartments = Power Apps Gallery Name
PowerApps Uncheck Checkbox Control When Another is Checked

6. Save, Publish, and Preview the app. When the user selects any product name from the checkbox control inside the gallery, the remaining checkbox controls automatically uncheck like below.

PowerApps Uncheck Checkbox Control When Another One Checked

Example-3: [Achieve Single Selection From Multiple Check Box Controls in Power Apps]

In the example below, you can see that after selecting Economy, if im selecting Business, the Economy option is unselected. The same thing is repeated for the Business check box.

How to achieve single selection from power apps check box controls

To achieve this, follow the steps below!

1. Provide the formula below in the OnCheck property of the Economy check box control in Power Apps.

UpdateContext({EconomySelected: true});
If(
    EconomySelected,
    UpdateContext({BusinessSelected: false})
);

Here, EconomySelected and BusinessSelected are Power Apps’ local variables. The above code describes,

  • The EconomySelected variable is set as true.
  • If the EconomySelected value is true, then the BusinessSelected variable value is updated as false.
only one checkbox selected at a time powerapps

2. Provide the variable name below in the Economy check box’s Default property:

EconomySelected

Here, the EconomySelected variable value is true, so this variable value will be changed when we check the business check box.

how do i select only one checkbox in powerapps

3. Provide the below formula in the OnCheck property of the Business check box control.

UpdateContext({BusinessSelected: true});
If(
    BusinessSelected,
    UpdateContext({EconomySelected: false})
);

Like in the above case, it works opposite to the economy check box selection. This means the EconomySelected variable is set to false if the BusinessSelecte variable is true.

powerapps uncheck checkbox when another is checked

4. Provide the variable below in the Business check box’s Default property:

BusinessSelected

This variable value changes based on the selection of the economy checkbox.

uncheck checkbox when another is checked in powerapps

5. To reset the checkboxes, provide the formula below in the Reset buttons OnSelect property.

UpdateContext(
    {
        EconomySelected: false,
        BusinessSelected: false
    }
);

Basically, with the Reset() function, we’ll reset the Power Apps controls. But here, the checkbox controls contain some default values, so even when we use the reset function, any checkbox is selected. So, we need to update the variables to false.

This way, we can reset the checkboxes which contain default values.

how to uncheck a checkbox when another is checked in power apps

I hope you understand how to uncheck a check box when another check box is checked in Power Apps.

You can adjust the variable names and the number of checkboxes. Even if you have three checkboxes, you follow the above steps, add an extra variable, and update it based on your requirements.

Conclusion

I trust this Power Apps tutorial taught in detail information about the Power Apps check and uncheck the checkbox control.

Here, we learned how to work with three checkbox controls. The remaining checkbox controls will be unchecked when the user selects any checkbox value in a Power Apps canvas app.

Also, we covered that in Power Apps, there is a checkbox control inside the gallery control; whenever the user selects any product name from the checkbox control, the remaining checkbox controls will uncheck.

You may also like:

>