Power Apps Checkbox control within Gallery

Would you like to work with the Check box control within the Power Apps gallery? If so, then this Power Apps tutorial will guide you on how to achieve this. We will also cover the following topics based on different scenarios.

  • Power Apps checkbox add from gallery to collection
  • Power Apps Select All checkbox in the gallery
  • Power Apps gallery checkbox multiple selections
  • Power Apps reset checkbox in the gallery
  • Power Apps set checkbox value in the gallery
  • Power Apps Gallery Checkbox disable
  • Power Apps Gallery Checkbox count
  • Power Apps Gallery Checkbox single select
  • Power Apps Gallery Checkbox disable based on time
  • Power Apps checkbox filter gallery

Power Apps checkbox add from gallery to collection

In this example, we will see how to add the check box selected item(s) from the Power Apps gallery to a Power Apps Collection. That means when the user selects any checkbox item(s), the selected items will be stored in a collection. Similarly, when the user unchecks the items from the checkbox control, the individual item will be removed from the collection.

To work with this requirement, the following steps are:

  • Suppose we have a SharePoint list named Projects having a Title column.
powerapps checkbox in gallery
Power Apps checkbox in the gallery
  • On the Power Apps environment, add a vertical gallery. Set the layout as Title to display only the title of the SharePoint list.
  • Then add a check box control to the vertical gallery. Insert the below expression on the checkbox’s Text property.
Text = ThisItem.Title

Now we can see, the check box has the data from SharePoint’s Title field shown below:

powerapps checkbox add gallery to collection
Power Apps checkbox add from gallery to collection
  • Next, insert the below expression within the checkbox’s OnCheck property, where we will create a collection to store the checked values from the gallery.
OnCheck = Collect(CollProjects,ThisItem)

Where CollProjects is the name of the collection name.

Add checkbox from gallery to collection in Power Apps
Add a checkbox from the gallery to the collection in Power Apps
  • Similarly, to remove the item from the collection once the item is unchecked insert the below expression on the OnUncheck property of the checkbox control.
OnUncheck = Remove(CollProjects,ThisItem)
Power Apps Add Checkbox values to collection from gallery
Power Apps Add Checkbox values to the collection from the gallery

Let’s preview the app and check some checkbox items from the gallery.

Power Apps checkbox add gallery to collection
Power Apps checkbox add from gallery to collection

We can see these checked items will be visible in the CollProjects collection.

Power Apps add checkbox values from gallery to collection
Power Apps add checkbox values from the gallery to the collection

Let’s uncheck some items from the gallery again.

Power Apps Set checkbox based on collection from gallery
Power Apps Set checkbox based on collection from gallery

We can see the collection which will be updated below:

Power Apps Update Collection based on gallery checkbox
Power Apps Update Collection based on gallery checkbox

This is how to update a collection based on the Power Apps gallery checkbox control.

Also Read: How To Set Default Value in Power Apps List Box Control

Power Apps Select All checkbox in the gallery

Within the Power Apps gallery, we will see how to select the All checkbox. That is, when the user selects a specific checkbox control named All, it automatically selects all of the remaining checkbox items in the gallery. Similarly, unchecking that checkbox control unchecks all of the checkboxes.

If this is the requirement, then follow the below solutions:

  • Suppose, we have a SharePoint list named Projects having a choice column called Skills.
powerapps select all checkbox in gallery
Power Apps select All check box in gallery
  • On the Power Apps, add a blank vertical gallery. Insert the below expression on the Gallery’s Items property to get all the choices from the Skills column.
Items = Choices(Projects.Skills)

Where Projects is the name of the SharePoint list and Skills is the name of the choice column. But it will display as blank shown below:

Power Apps select all checkbox in gallery
Power Apps select All check box in the gallery
  • Next, insert a check box control to the above blank vertical gallery and insert the below expression in the control’s Text property to show all the choices with the respective check box controls.
Text = ThisItem.Value
select all checkbox in gallery power apps
select All check box in the gallery power apps
  • Add another Power Apps check box control to the screen and place it just above the gallery (Outside of the gallery).
  • Give a Text to the check box as “All”.
select all checkbox in gallery PowerApps
select All check box in the gallery PowerApps
  • Insert the below expression on the All checkbox’s OnCheck property.
OnCheck = Set(VarAllCheckbox, true)

Where VarAllCheckbox is the name of the global variable name.

Power Apps Select all checkbox outside gallery to select checkbox inside gallery
Power Apps Select All check box outside the gallery to select the checkbox inside a gallery
  • Similarly, insert the below expression in the All checkbox’s OnUncheck property.
OnUncheck = Set(VarAllCheckbox, false)
Selecting All Checkbox in Power Apps gallery
Selecting All Checkbox in the Power Apps gallery
  • Update the global variable name within the Default property of the Gallery’s checkbox control.
Default = VarAllCheckbox
How to make a Select All Checkbox in Power Apps
How to make a Select All Checkbox in Power Apps

Let’s preview the app and we can see when we check the All checkbox control, it will automatically check all the checkbox controls within the gallery.

Master CheckBox to select all checkboxes in Power Apps gallery
Master CheckBox to select all checkboxes in the Power Apps gallery

This is how to create a master CheckBox to select all checkboxes within the Power Apps gallery.

Check Out: Power Apps Listbox items from SharePoint list

Power Apps gallery checkbox multiple selections

This section will look at how to use the Power Apps’ multiple selection checkbox control. That is, if the user selects multiple items from the Power Apps gallery, it will display all of those items. In addition, when the user removes items from the check box control, it displays all of the updated items.

To work with this requirement we will use the above Power Apps gallery and the following steps are:

  • On that Power Apps gallery, select the checkbox control and insert the below expression on the checkbox’s OnCheck property.
OnCheck = Collect(CollSkills, ThisItem.Value)

Where CollSkills is the name of the collection.

powerapps gallery checkbox multiple selection
Power Apps gallery checkbox multiple selections
  • Insert the below expression on the checkbox control’s OnUncheck property.
OnUncheck = RemoveIf(CollSkills, Value = ThisItem.Value)
Power Apps gallery checkbox multiple selection
Power Apps gallery checkbox multiple selections
  • Next, add a data table to display the multi-selected checkbox items. Select the data table and go to Fields > Edit fields > Add fields > Value.
  • Then insert the below expression on the data table’s Items property.
Items = CollSkills.Value
Multi-select Items from Power Apps Gallery Checkbox control
Multi-select Items from Power Apps Gallery Checkbox control

Let’s preview the app and select multiple checkbox controls from the gallery.

Multi Select Items in Power Apps Gallery using Checkbox
Multi Select Items in Power Apps Gallery using Checkbox

Similarly, if we unchecked the checkbox controls, the data table will be updated like the below:

Select Multiple checkbox controls in a Power Apps Gallery
Select Multiple checkbox controls in a Power Apps Gallery

This is how to select Multiple checkbox controls in a Power Apps Gallery.

Have a look: How to use Power Apps List box control?

Power Apps reset checkbox in the gallery

In this section, we’ll look at how to reset the checkbox control(s) in the Power Apps gallery. That means the Power Apps gallery contains a reset icon or button. When the button or icon is clicked, all of the selected checkbox controls are reset, allowing the user to select the options as needed.

To work with this requirement, we will use the above example of the Power Apps gallery. The following steps are:

  • Add a Reload icon to the Power Apps screen and place it in the top corner of the gallery.
  • Insert the below expression on the Reload icon’s OnSelect property.
OnSelect = UpdateContext({VarChecked:true});UpdateContext({VarChecked:false}); 

Where VarChecked is the name of the UpdateContext variable name (local variable).

PowerApps reset checkbox in gallery
PowerApps reset checkbox in the gallery
  • Select the gallery’s checkbox control and set the update context variable name within the Reset property of the checkbox control.
Reset = VarChecked
Reset Power Apps Checkboxes in Gallery
Reset Power Apps Checkboxes in Gallery

That’s all! Let’s preview the app and check some items from the Gallery’s Power Apps Checkboxes. As we can see, clicking the Reload icon resets the checkbox controls within the gallery.

This is how to reset the Power Apps Checkboxes in the Gallery.

Read: Power Apps combo box default value

Power Apps set checkbox value in the gallery

In this section, we’ll look at how to set the checkbox values in the Power Apps gallery. That is, when the user selects a value from the dropdown list, the gallery’s checkbox will be checked accordingly.

Power Apps set checkbox value in gallery
Power Apps set checkbox value in the gallery
  • On the Power Apps screen, build a dropdown control to retrieve the choices from the Department column.
PowerApps set checkbox value in gallery
PowerApps set checkbox value in the gallery
  • Add a vertical gallery to display the workers’ Names.
Set checkbox value in Power Apps gallery
Set checkbox value in Power Apps gallery
  • Add a checkbox control to the Power Apps gallery. Insert the below expression in the checkbox control’s Text property.
Text = ThisItem.Department.Value

Now the checkbox has the values as Finance, HR, and IT like below:

Power Apps checkbox in Gallery
Power Apps checkbox in Gallery
  • Next, insert the below expression into the checkbox control’s Default property to check the controls automatically as per the dropdown selection.
Default = Department_dd.Selected.Value in ThisItem.Department.Value

Where Department_dd is the name of the dropdown control.

Set value of checkbox in a Power Apps Gallery Item
Set the value of the checkbox in a Power Apps Gallery Item

Now preview the app. Select an item from the dropdown control(ex: IT). We can see the person who belongs to that selected department, the respective checkbox will be checked like below:

Set the value of a Checkbox Within a Power Apps Gallery
Set the value of a Checkbox Within a Power Apps Gallery

This is how to set the value of a Checkbox Within a Power Apps Gallery.

Also Check: Power Apps Combo box with SharePoint list

Power Apps Gallery Checkbox disable

Here, we will see how to disable a checkbox control within the Power Apps gallery. That means when the user selects a check box control within the gallery, another check box will be disabled.

To work with this scenario, the following steps are:

  • We have prepared a vertical gallery to display the user’s name.
  • Inside that gallery, add 2 check box controls to that Power Apps gallery and rename them as “Active”, and “Not Active”.
Power Apps Gallery Checkbox disable
Power Apps Gallery Checkbox disable
  • Select the Active checkbox control and insert the below expression on the DisplayMode property.
DisplayMode = If(NotActive_Checkbox.Value, DisplayMode.Disabled, DisplayMode.Edit)

Where NotActive_Checkbox is the name of the ‘Not Active’ check box control name.

PowerApps Gallery Checkbox disable
PowerApps Gallery Checkbox disable
  • Similarly, insert the below expression on the ‘Not Active’ checkbox’s DisplayMode property.
DisplayMode = If(Active_Checkbox.Value, DisplayMode.Disabled, DisplayMode.Edit)

Where Active_Checkbox is the name of the ‘Active’ Checkbox control name.

Disable checkbox on selection of other check box in Power Apps gallery
Disable the checkbox on the selection of another check box in the Power Apps gallery

Let’s preview the app and we can see when selecting any check box control, then another one will be disabled like the below:

How to disable a check box if the other check box is checked in Power Apps gallery
How to disable a check box if the other check box is checked in the Power Apps gallery

This is how to disable a check box if the other check box is checked in the Power Apps gallery.

Read: Power Apps combo box filter

Power Apps Gallery Checkbox count

In this section, we’ll look at how to count the checkbox control in the Power Apps gallery. That is when a user checks any Power Apps checkbox control (s) in the Power Apps gallery, the total count of the checked checkbox control is displayed.

Suppose, we have a specific SharePoint list named Projects having a choice column named Skills. To work with the above requirement, the following steps are:

  • On the Power Apps screen, add a Blank vertical gallery. Insert the below expression on the Items property f the gallery.
Items = Choices(Projects.Skills)
  • Then add a checkbox control to the blank vertical gallery. Insert the below expression on the checkbox’s Text property. As a result, the checkbox has choices from the ‘Skills‘ choice column.
Text = ThisItem.Value
Power Apps Gallery Checkbox count
Power Apps Gallery Checkbox count
  • To count the selected checkbox control within the gallery, add a Text Label control to the Power Apps screen and place the control outside of the gallery. Insert the below expression on the Label’s Text property.
Text = CountRows(Filter(Skills_Gallery.AllItems, Skills_Chckbx.Value))
PowerApps Gallery Checkbox count
PowerApps Gallery Checkbox count

Let’s check out the app. When we select the checkbox control(s) from the Power Apps gallery, the label control displays the total count of the checked checkbox controls.

Count number of checked items within a gallery
Count the number of checked items within a Power Apps gallery

This is how to count the number of checked items within a Power Apps gallery.

Check: How to Patch Power Apps Combo Box

Power Apps Gallery Checkbox single select

In this section, we will discuss how to work with the Power Apps Gallery Checkbox, which will be set to single select. That is, it will allow the user to select a single option from the Power Apps gallery control’s checkboxes.

To work with this requirement, we will use the above “Workers” SharePoint list and the following steps are:

  • On the Power Apps screen, add a vertical gallery and keep the layout as Title to display the name of the workers.
Power Apps Gallery Checkbox single select
Power Apps Gallery Checkbox single select
  • Next, add another blank vertical gallery within the above gallery. Insert the below expression on the Items property of the blank vertical gallery.
Items = Choices(Workers.Department)
  • Inside that blank gallery, add a checkbox control and set the below formula in the checkbox’s Text property to display the choices in the respective checkbox controls.
Text = ThisItem.Value
Select single checkbox inside a Gallery
Select a single checkbox inside a Gallery
  • Add a label control to the inside gallery that displays the departments. Make sure to keep it in front of the checkbox control. Insert the below expression on the label’s visible property.
Visible = !ThisItem.IsSelected || !Department_Checkbox.Value

Where Department_Checkbox is the name of the checkbox control.

PowerApps Gallery Checkbox single select
PowerApps Gallery Checkbox single select
  • Keep the label’s text color and the gallery’s background color the same. Let’s preview the app. we can see, it will allow us to select any one checkbox control at a time within the Power Apps gallery.
Allow Checkbox single select within the Power Apps gallery
Allow Checkbox single select within the Power Apps gallery

This is how to set the check box control for a single selection within the Power Apps gallery.

Read: How to Sort Combo Box Items in Power Apps

Power Apps Gallery Checkbox disable based on time value

Here, we will see how to disable the Powe Apps gallery checkbox controls based on the time value.

That is, if the checkbox value is less than the current time, the checkbox will be disabled within a Power Apps gallery. As a result, the user will only be able to select a future time like the below:

Power Apps Gallery Checkbox based on time
Power Apps Gallery Checkbox based on time

We can see, it will disable the check box controls whose time value is less than the current time value. To work with this scenario, the following steps are:

  • We have prepared a SharePoint list named Interviews having a choice column as well as the choices like below:
PowerApps Gallery Checkbox based on time
PowerApps Gallery Checkbox based on time
  • On the Power Apps screen, add a vertical gallery and connect the gallery with the desired SharePoint list i.e., Interviews to display the other details of the list such as Title, and Interviewer’s name.
Power Apps Gallery Checkbox based on time
Power Apps Gallery Checkbox based on time
  • Inside the above vertical gallery, add another blank gallery and insert the below expression on the gallery’s Items property.
Items = Choices(Interviews.'Time Slots')
  • But the gallery will display as blank. Add a checkbox control to that blank gallery and insert the below expression on the checkbox’s Text property.
Text = ThisItem.Value

Now the blank gallery’s check box has its own values that retrieve from SharePoint’s Time Slot column.

Set Power Apps Gallery Checkbox value based on time
Set Power Apps Gallery Checkbox value based on time
  • To disable the checkbox based on the time value, insert the below expression on the checkbox’s DisplayMode property.
DisplayMode = If(TimeValue(Now()) > TimeValue(ThisItem.Value), DisplayMode.Disabled,Edit)
Power Apps gallery check box disable based on time
Power Apps gallery check box disable based on time

We can see it will disable the past time and let the user select time slots from the future time.

To get the current time, add a label control to the screen and place it above the gallery control. Insert the below expression on the label’s Text property.

Text = "The current Time: " & Now()
Power Apps Gallery Checkbox disable based on time
Power Apps Gallery Checkbox disable based on time

As the current time is ‘7:09 PM‘, so it disables all the past time values i.e., 8:30 AM, and 11:30 AM.

This is how to disable the checkbox controls within the Power Apps gallery based on the time value.

Power Apps checkbox filter gallery

Would you like to filter the gallery based on checkbox selection whether it is a single selection or multiple selections?

Recently, we published an article where we described how to filter a Power Apps gallery based on multiple checkbox controls. We recommend you follow the mentioned link to get the answer.

Furthermore, have a look at the below more tutorials:

Conclusion

From this Power Apps Tutorial, we learned how to work with checkbox control within a Power Apps gallery based on different types of situations such as:

  • Power Apps checkbox add from gallery to collection
  • Power Apps Select All checkbox in the gallery
  • Power Apps gallery checkbox multiple selections
  • Power Apps reset checkbox in the gallery
  • Power Apps set checkbox value in the gallery
  • Power Apps Gallery Checkbox disable
  • Power Apps Gallery Checkbox count
  • Power Apps Gallery Checkbox single select
  • Power Apps Gallery Checkbox disable based on time
  • Power Apps checkbox filter gallery
>