Power Apps Checkbox in a Gallery: Select All, Reset, Count and More

Checkboxes in a gallery look simple until you try to do something with them. On one project, the team wanted to tick several projects in a list and act on all of them at once, with a “select all” option, a reset button and a running count of how many were ticked. Each of those needed a slightly different trick, because the checkboxes sit inside the gallery, one per row.

In this tutorial, I’ll walk you through the scenarios I use most often, each with the formulas. The screenshots use the classic Check box control, and I’ll point out where the modern Checkbox is different, because its property names aren’t the same.

Quick answer: Add a Check box inside the gallery’s template, so every row gets its own. Use OnCheck with Collect(colSelected, ThisItem) and OnUncheck with Remove(colSelected, ThisItem) to track the ticked rows. Count them with CountRows(colSelected), and reset them by toggling a variable in the check box’s Reset property (classic) or by clearing the collection that drives Checked (modern).

Classic vs modern checkbox

Before you start, check which control you’re using. The classic Check box uses Text for its label, Default for its starting state, Value for whether it’s ticked, and has a Reset property (classic Check box reference).

The modern Checkbox uses Label and Checked instead, and it has no Default, Value or Reset property (modern Checkbox reference). Both have OnCheck, OnUncheck and DisplayMode, so most formulas below work on both once you swap .Value for .Checked.

1. Add checked items to a collection

The foundation for most checkbox scenarios is a collection that always holds the ticked rows. My example uses a SharePoint list called Projects with a Title column:

SharePoint list Projects used in the Power Apps checkbox gallery

Add a vertical gallery connected to the list, then insert a check box into the gallery’s template and set its Text property to ThisItem.Title. Every row now shows a checkbox labelled with the project name:

Checkboxes showing SharePoint titles inside a Power Apps gallery

Set the check box’s OnCheck property to add the row to a collection called CollProjects:

Collect(CollProjects, ThisItem)
OnCheck property adding a gallery item to a collection

And set OnUncheck to remove it again:

Remove(CollProjects, ThisItem)
OnUncheck property removing a gallery item from a collection

Play the app and tick a few projects:

Checked items in a Power Apps gallery

Those projects now appear in the collection:

Collection holding the checked gallery items

Untick some of them, and the collection updates straight away:

Unchecking items in the Power Apps gallery
Collection updated after unchecking items

Remove() only takes out one copy of a matching record, which is exactly what you want here, since each row is collected once. The collection is also what you’d use to act on the selection later, for example with ForAll(CollProjects, Patch(...)).

2. Select all checkboxes with one checkbox

For this example, the list has a Choice column called Skills, and the gallery shows one checkbox per choice:

SharePoint Choice column Skills used for the checkbox gallery

Add a blank vertical gallery and set its Items property to the column’s choices:

Choices(Projects.Skills)
Blank gallery with Items set to Choices in Power Apps

Insert a check box in the gallery and set its Text to ThisItem.Value:

Checkboxes showing the Skills choices in the gallery

Now add another check box outside the gallery, just above it, and set its Text to All:

All checkbox placed above the Power Apps gallery

Set the All checkbox’s OnCheck to Set(VarAllCheckbox, true) and its OnUncheck to Set(VarAllCheckbox, false):

OnCheck of the All checkbox setting a variable to true
OnUncheck of the All checkbox setting a variable to false

Finally, set the Default property of the checkbox inside the gallery to the variable (on the modern control, use Checked):

VarAllCheckbox
Default of the gallery checkbox set to the select-all variable

Ticking All now ticks every checkbox in the gallery, and unticking it clears them all:

Select all checkbox ticking every checkbox in the Power Apps gallery

If your gallery also collects the ticked rows, the easiest way to keep the collection in step is to fill or clear it in the same formulas, for example Set(VarAllCheckbox, true); ClearCollect(CollSkills, Choices(Projects.Skills)).

3. Show multiple selections

Using the same Skills gallery, you can list everything that’s been ticked. Set the gallery checkbox’s OnCheck to:

Collect(CollSkills, ThisItem.Value)
OnCheck collecting the selected skill in Power Apps

And its OnUncheck to remove that skill from the collection:

RemoveIf(CollSkills, Value = ThisItem.Value)
OnUncheck removing the skill from the collection with RemoveIf

Then add a data table next to the gallery, set its Items to CollSkills, and add the Value field under Edit fields:

Data table showing the selected skills from the collection

As you tick skills, they appear in the table, and unticking removes them:

Multiple checkbox selections shown in a data table
Data table updated after unticking checkboxes

4. Reset the checkboxes in a gallery

This is where people often get stuck. The Reset() function can’t reset controls inside a gallery from a button outside it; Microsoft’s Reset reference says so explicitly. For the classic check box, the solution is its Reset property, which resets the control whenever it becomes true.

Add a reload icon above the gallery and set its OnSelect to switch a variable on and straight off again:

UpdateContext({VarChecked: true}); UpdateContext({VarChecked: false})
Reload icon OnSelect toggling a variable to reset checkboxes

Then set the Reset property of the checkbox inside the gallery to VarChecked:

Reset property of the gallery checkbox set to the variable

Selecting the icon now clears every checkbox in the gallery. Remember to clear any collection too, for example with Clear(CollSkills) in the same OnSelect.

Resetting a modern checkbox in a gallery

The modern Checkbox has no Reset or Default property, so the toggle trick doesn’t apply. The approach I use instead is to let the collection decide whether each row is ticked. Set the modern checkbox’s Checked property to:

!IsBlank(LookUp(CollProjects, ID = ThisItem.ID))

Keep OnCheck and OnUncheck adding and removing the row as in scenario 1. To reset every checkbox, all you need is Clear(CollProjects): the collection empties, and every checkbox follows it.

5. Tick checkboxes based on another control

In this scenario, a list of workers has a Department column, and picking a department from a dropdown should tick the workers who belong to it:

Checkboxes ticked based on a dropdown selection in Power Apps

Add a dropdown with the Department choices, and a gallery showing the workers:

Dropdown showing Department choices in Power Apps
Gallery showing worker names in Power Apps

Insert a check box in the gallery with its Text set to ThisItem.Department.Value, so each row shows its department:

Checkboxes showing each worker's department

Then set the check box’s Default so it’s ticked when its department matches the dropdown, where Department_dd is the dropdown’s name:

Department_dd.Selected.Value in ThisItem.Department.Value
Default of the checkbox comparing the dropdown selection

Pick IT in the dropdown, and the checkboxes for IT workers are ticked:

Checkboxes ticked for workers in the selected department

6. Disable one checkbox when another is ticked

Sometimes a row has two options that shouldn’t both be ticked, such as Active and Not Active. Put two check boxes in the gallery template and name them Active_Checkbox and NotActive_Checkbox:

Two checkboxes Active and Not Active in a Power Apps gallery

Set the DisplayMode of the Active checkbox to:

If(NotActive_Checkbox.Value, DisplayMode.Disabled, DisplayMode.Edit)
DisplayMode of the Active checkbox

And the DisplayMode of the Not Active checkbox to the opposite:

If(Active_Checkbox.Value, DisplayMode.Disabled, DisplayMode.Edit)
DisplayMode of the Not Active checkbox

Now, ticking one option disables the other on the same row:

Checkbox disabled when the other checkbox is ticked

For more on how DisplayMode works, see Power Apps DisplayMode.

7. Count the ticked checkboxes

Back to the Skills gallery. To show how many skills are ticked, add a label outside the gallery:

Skills gallery with checkboxes for counting in Power Apps

Set the label’s Text to count the rows whose checkbox is ticked, using the gallery’s AllItems property. Microsoft uses the same pattern in its bulk update example:

CountRows(Filter(Skills_Gallery.AllItems, Skills_Chckbx.Value))
Label counting the checked checkboxes in a Power Apps gallery

The count updates as you tick and untick:

Count of checked checkboxes shown in a label

This works well for short galleries like a list of skills. For long galleries, be careful: AllItems only contains the rows that have been loaded so far, not every item (gallery best practices). In that case, count the collection instead, with CountRows(CollSkills).

8. Allow only one checkbox per row

In this example, each worker in a gallery has a nested gallery of department checkboxes, and only one department should be ticked per worker:

Gallery of workers for single-select checkboxes

The nested gallery’s Items is Choices(Workers.Department), and its checkbox shows ThisItem.Value:

Nested gallery with department checkboxes

The trick in the original app is a label placed in front of each checkbox, whose Visible property hides it only on the selected row. Its fill matches the gallery background, so the other checkboxes are covered while one is ticked:

!ThisItem.IsSelected || !Department_Checkbox.Value
Label Visible property used to allow a single checkbox selection
Only one checkbox can be ticked per row in the Power Apps gallery

It works, but it’s a visual trick. If you’re building this today, a Radio control is the cleaner choice, because it’s designed for exactly this: several options, only one of which can be selected.

9. Disable checkboxes for times that have passed

For an interview booking app, time slots in the past shouldn’t be selectable:

Past time slots disabled in a Power Apps gallery

The time slots come from a Choice column called Time Slots in an Interviews list:

SharePoint Choice column with interview time slots

A gallery shows each interview, and a nested gallery inside it shows the slots, with Items set to Choices(Interviews.'Time Slots') and a checkbox showing ThisItem.Value:

Gallery showing interviews from SharePoint
Nested gallery with time slot checkboxes

Set the checkbox’s DisplayMode so slots earlier than the current time are disabled. TimeValue() converts the slot text, such as 8:30 AM, into a time, and the formula compares only the time of day:

If(
    TimeValue(ThisItem.Value) < TimeValue(Text(Now(), "hh:mm AM/PM")),
    DisplayMode.Disabled,
    DisplayMode.Edit
)
DisplayMode formula disabling past time slots

To make it easy to check, I added a label above the gallery showing the current time with "The current time: " & Text(Now(), "hh:mm AM/PM"). At 7:09 PM, the 8:30 AM and 11:30 AM slots are disabled:

Label showing the current time above the gallery

Filter a gallery with checkboxes

The opposite scenario, using checkboxes outside a gallery to filter what it shows, is covered in how to filter a Power Apps gallery by radio button and our other gallery filter guides.

These Power Apps gallery and collection tutorials go well with this one:

Frequently Asked Questions

How do I get the checked items from a gallery in Power Apps?

Collect them as they’re ticked: set the checkbox’s OnCheck to Collect(CollProjects, ThisItem) and OnUncheck to Remove(CollProjects, ThisItem). The collection always holds the checked rows.

How do I reset checkboxes in a Power Apps gallery?

Reset() can’t reset controls inside a gallery from outside it. For the classic check box, set its Reset property to a variable and toggle it with Set(var, true); Set(var, false). For the modern checkbox, drive Checked from a collection and clear the collection.

How do I select all checkboxes in a Power Apps gallery?

Add an All checkbox outside the gallery that sets a variable in OnCheck and OnUncheck, and set the gallery checkbox’s Default (classic) or Checked (modern) to that variable.

How do I count checked checkboxes in a gallery?

Use CountRows(Filter(Gallery.AllItems, Checkbox.Value)) for short galleries, or count the collection of checked items with CountRows(CollSkills), which also works for long galleries.

What is the difference between the classic and modern checkbox?

The classic Check box uses Text, Default, Value and a Reset property. The modern Checkbox uses Label and Checked and has no Default, Value or Reset property.

1 thought on “Power Apps Checkbox in a Gallery: Select All, Reset, Count and More”

  1. We need information about how to remove items from collection when checkbox is unchecked after using Select All checkbox outside of gallery.

Comments are closed.