Power Apps Uncheck Checkbox When Another is Checked

Recently, I got a requirement from one of my clients to uncheck a checkbox when another is checked in Power Apps. So, I thought I would explain it in detail here. Follow this Microsoft Power Apps tutorial to learn all about the “Power Apps uncheck checkbox when another is checked” with two examples.

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]. Whenever the user selects any one checkbox value, the remaining checkbox controls will be unchecked.

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 below-mentioned steps.

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 Check box control, we can select multiple check box values. However, our requirement is the 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

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:

>