Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

Power Apps Select All Checkbox in Gallery: Check, Count and Use Rows

Our service desk team reviews new requests in a Power Apps screen every morning. Checking six boxes one by one got old fast, so they asked me for one box at the top of the list that checks every row, plus a count of how many rows are picked.

That box is a Power Apps checkbox in a gallery header, and it’s easy to get almost right. The common version works until someone unchecks a single row, then the count and the header disagree.

In this tutorial, we’ll build a power apps select all checkbox in gallery with modern controls. You’ll wire it two ways (a variable and a collection of selected IDs), count the checked rows, fix the partial selection case and save the picked rows to SharePoint.

Here’s what we’re building. One click on Select all checked all six New requests, shaded them blue and listed their IDs:

Power Apps gallery with Select all checked, six rows highlighted and Selected 6 of 6 with their IDs
  • A Select all checkbox above a gallery of Service Requests.
  • A live count such as “Selected: 5 of 6” that answers how many boxes are checked.
  • A collection (an in-memory table) named colSaPicked holding the picked IDs.
  • Buttons that send the picked rows to review or save them to a SharePoint list.

What You Need to Build a Select All Checkbox in Power Apps

You need a Power Apps license that covers the SharePoint connector and an app with modern controls turned on. I built everything in our SPGuides tenant on a responsive app. If you just want to check several rows without a header box, start with selecting multiple items in a Power Apps gallery.

The gallery reads the Service Requests list, and the save button writes to a second list:

ListColumnTypeUsed for
Service RequestsTitleSingle line of textLaptop replacement #1000, Printer jam #1003
Service RequestsStatusChoiceNew, In Progress, Closed (filters the gallery)
Service RequestsIDNumber (built in)What the collection stores
IT Help RequestsTitleSingle line of text“Demo select all – VPN access #1001”
Service Requests SharePoint list with Title, Status and Priority columns

Both lists are already connected through Add data > SharePoint in my app. A data source is simply a connected list the app can read and write.

Step 1: Add a Header and Footer Screen

We start with a responsive Power Apps screen so the cards line up on any width. Select New screen on the toolbar and pick Header and footer (a header, a main area and a footer, each an auto-layout container).

Power Apps New screen menu with the Header and footer layout highlighted

Select the main container, open Insert, type Checkbox and pick Checkbox under Input. That’s the modern control. Add one for Select all now, and add a vertical gallery from the same menu.

Power Apps Insert menu search for Checkbox showing the modern Checkbox under Input

Open the property dropdown to the left of the fx formula bar. The modern checkbox lists OnCheck and OnUncheck, but no OnSelect and no Value. The Power Apps modern checkbox control post walks through the rest of its properties.

Modern checkbox property dropdown showing OnCheck and OnUncheck with no OnSelect

Checkpoint: you have a Header and footer screen with a modern checkbox named chkSaAll1 and a gallery named galSaReq1 in the main container.

Step 2: Wire the Select All Checkbox to a Variable

Goal: one click on Select all checks every row. Set the gallery’s Items to FirstN(Filter('Service Requests', Status.Value = "New"), 6), then insert a modern checkbox into the gallery template (chkSaRow1) with Label ThisItem.Title.

Select chkSaAll1, pick OnCheck in the property dropdown and type the line below. It stores true in a global variable (Power Apps creates it the first time Set runs):

Set(varSaAll, true)
chkSaAll1 selected with OnCheck set to Set varSaAll true in the formula bar

Its OnUncheck sets the same variable back to false:

Set(varSaAll, false)

Now select the row checkbox chkSaRow1 and set its Default to the variable. Every row reads it, so flipping the variable clicks all checkboxes at once:

varSaAll
Gallery row checkbox chkSaRow1 with Default set to varSaAll

Note: in our Studio the input property is called Default and the output is .Checked. Microsoft’s newer reference calls the input Checked, so use whichever name your property list shows.

Step 3: Count How Many Checkboxes Are Checked in the Gallery

The team also wanted to see how many checks are in the list. The gallery’s AllItems property is the table of loaded rows, including each row’s controls, so we can filter it on the checkbox. Add a modern text label and set its Text to:

"Checked: " & CountRows(
    Filter(
        galSaReq1.AllItems,
        chkSaRow1.Checked
    )
) & " of " & galSaReq1.AllItemsCount & "  |  Select all: " & chkSaAll1.Checked
Text formula counting checked rows with CountRows Filter galSaReq1.AllItems chkSaRow1.Checked

CountRows counts the rows that pass the filter, and AllItemsCount gives the total. Our count rows in a Power Apps gallery tutorial shows more counting patterns.

Checkpoint: in Play mode, clicking Select all checks all six rows and the label reads “Checked: 6 of 6 | Select all: true”.

Preview with Select all checked, six gallery rows checked and Checked 6 of 6

Why the Power Apps Variable Version Breaks on One Unchecked Row

Same screen, one more click. I unchecked Printer jam #1003. The count dropped to five, but the header box stayed checked, because nothing ever tells varSaAll that one row changed:

Printer jam row unchecked while Select all stays checked and the label shows 5 of 6

The label read “Checked: 5 of 6 | Select all: true”. Unchecking Select all then cleared every row, and checking it again re-checked all six, including #1003. That’s fine for a quick Power Apps filter screen, but the header lies whenever the selection is partial.

The fix is to stop storing “all or nothing” and store which rows are picked instead.

Step 4: Track the Selected Rows in a Collection

Goal: a collection named colSaPicked that holds the ID and Title of every checked row. For this version I used a second gallery, galSaReq2, with a status drop-down above it and Items set to:

FirstN(Filter('Service Requests', Status.Value = ddSaStatus.Selected.Value), 6)

This is also how you set a checkbox value in a Power Apps gallery from data. Set the row checkbox chkSaRow2’s Default so a row shows checked when its ID is in the collection:

ThisItem.ID in colSaPicked.ID
Gallery row checkbox chkSaRow2 with Default ThisItem.ID in colSaPicked.ID

Its OnCheck adds the row once. The If guard skips rows that are already in the collection:

If(
    Not(ThisItem.ID in colSaPicked.ID),
    Collect(
        colSaPicked,
        {
            ID: ThisItem.ID,
            Title: ThisItem.Title
        }
    )
)
chkSaRow2 OnCheck formula with If Not ThisItem.ID in colSaPicked.ID then Collect

OnUncheck removes it again (the Remove vs RemoveIf comparison explains why RemoveIf fits here):

RemoveIf(colSaPicked, ID = ThisItem.ID)

To shade picked rows, set the gallery’s TemplateFill to the formula below. Two labels show the count and the IDs:

If(ThisItem.ID in colSaPicked.ID, RGBA(222, 236, 249, 1), RGBA(0, 0, 0, 0))
"Selected: " & CountRows(colSaPicked) & " of " & galSaReq2.AllItemsCount
"Selected IDs: " & Coalesce(Concat(colSaPicked, ID, ", "), "(none)")

Step 5: Make the Select All Checkbox Follow the Rows

Now the header box reads the collection instead of a variable. Set chkSaAll2’s Default so it’s true only when every loaded row is in colSaPicked:

!IsEmpty(galSaReq2.AllItems) && CountRows(
    Filter(
        galSaReq2.AllItems,
        ID in colSaPicked.ID
    )
) = galSaReq2.AllItemsCount
Select all Default formula comparing picked rows with galSaReq2.AllItemsCount

Its OnCheck copies every loaded row into the collection. ShowColumns keeps just the ID and Title, and ClearCollect replaces whatever was there (see Power Apps collections for Collect vs ClearCollect):

ClearCollect(
    colSaPicked,
    ShowColumns(
        galSaReq2.AllItems,
        ID,
        Title
    )
)
Select all OnCheck formula ClearCollect colSaPicked ShowColumns galSaReq2.AllItems ID Title

And OnUncheck empties it:

Clear(colSaPicked)

Checkpoint: clicking Select all on the New view checks six rows, shades them blue and shows “Selected: 6 of 6” and “Selected IDs: 1, 6, 7, 9, 13, 18”.

Test the Select All Gallery With a Partial Selection

Select Play at the top right (or hold Alt and click in the editor) and repeat the test that broke the variable version. I unchecked Printer jam #1003 again:

Select all unchecks itself after one row is cleared, Selected 5 of 6 with IDs 1, 7, 9, 13, 18
  • Select all unchecked itself, and the other five rows stayed checked.
  • The labels read “Selected: 5 of 6” and “Selected IDs: 1, 7, 9, 13, 18”.
  • Re-checking #1003 checked Select all again; the IDs became “1, 7, 9, 13, 18, 6” with no duplicate.
  • Unchecking Select all cleared everything: “Selected: 0 of 6”.

The header’s OnUncheck didn’t fire when its Default turned false, which is why the five rows survived. In my Power Apps tests, only a real click ran OnCheck or OnUncheck.

Step 6: Do Something With the Selected Rows

In Power Apps, a selection is only useful if a button acts on it. Add two modern buttons and give both the DisplayMode below, so they’re grayed out until a row is picked:

If(IsEmpty(colSaPicked), DisplayMode.Disabled, DisplayMode.Edit)

The first button, Send to review, copies the picks into a second collection and shows a banner:

ClearCollect(colSaReview, colSaPicked);
Notify(CountRows(colSaReview) & " requests sent to review", NotificationType.Success)

The second, Save to SharePoint, runs Patch once per picked row with ForAll. Our patch gallery items in Power Apps post covers bulk updates of existing items too:

ForAll(
    colSaPicked As p,
    Patch(
        'IT Help Requests',
        Defaults('IT Help Requests'),
        {Title: "Demo select all - " & p.Title}
    )
);
Notify(
    CountRows(colSaPicked) & " rows saved to IT Help Requests",
    NotificationType.Success
)
Save to SharePoint OnSelect with ForAll colSaPicked As p and Patch to IT Help Requests

I kept two rows, VPN access #1001 and Teams phone #1004, and clicked each button once. Send to review showed “2 requests sent to review”, and Save showed a green banner:

Green banner 2 rows saved to IT Help Requests after clicking Save to SharePoint

Checkpoint: IT Help Requests gets two new items titled “Demo select all – VPN access #1001” and “Demo select all – Teams phone #1004”. A Clear selection button with Clear(colSaPicked) grays both buttons out again.

For heavier work, like emailing every requester, I’d pass the picked IDs to a Power Automate flow instead of looping Patch inside Power Apps. The flow runs in the cloud, so the user can close the app.

Check a Power Apps Checkbox Value and Use If Checked

A few readers land here asking how to read a checkbox value. On the modern Power Apps control, the value is .Checked, which is true or false. The classic control uses .Value, as in our Power Apps checkbox value post. A label shows it directly:

"chkSaUrgent.Checked = " & chkSaUrgent.Checked

For “if checkbox is checked” logic, put .Checked inside If. I used an Urgent request box:

If(
    chkSaUrgent.Checked,
    "Route to the on-call technician",
    "Normal queue (next business day)"
)
If formula using chkSaUrgent.Checked to choose between two routing messages

Unchecked, the labels read “chkSaUrgent.Checked = false” and “Normal queue (next business day)”. After one click they changed to true and “Route to the on-call technician”:

Urgent request checkbox checked with Checked equals true and the on-call routing message

Why the Power Apps Select All Checkbox Misses Rows (and the Fix)

Two limits caught me while testing, and both come from the same fact: Select all only sees the rows the Power Apps gallery shows right now.

Filter changes. I picked two New rows (IDs 1 and 7), then switched the drop-down to In Progress. No row was checked and Select all was clear, yet the label said “Selected: 2 of 6” because the hidden picks were still in the collection:

In Progress rows unchecked while the label still says Selected 2 of 6 from hidden New picks

Clicking Select all there gave “Selected IDs: 4, 5, 10, 11, 14, 16”. ClearCollect replaced the two New picks. If users should keep picks across filters, use Collect with the same If guard instead.

Large lists. I pointed the first gallery at the whole Service Requests list (620+ items) and clicked Select all. The label read “Checked: 100 of 100”, and only after scrolling down did it grow to “200 of 200”. AllItems holds loaded rows only, a different limit from Power Apps delegation:

Gallery over the full list with Select all checked and Checked 100 of 100

Important: for “act on every matching item”, don’t rely on the gallery. Run ForAll over a Filter of the data source, or cap the gallery with FirstN so the count is honest. The same rule applies when the gallery reads a Dataverse table.

Reuse the Select All Checkbox in Your Own Power Apps

Power Apps keeps adding modern controls, so browse our Power Apps tutorials for the next build.

A few more Power Apps posts that pair well with this one:

Power Apps Select All Checkbox: Common Questions

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

Put a modern checkbox above the gallery. The simple way sets a variable in its OnCheck and OnUncheck and binds each row’s Default to it. The robust way fills a collection with ShowColumns(Gallery.AllItems, ID, Title) and sets each row’s Default to ThisItem.ID in colSaPicked.ID.

How do I count how many checkboxes are checked in a gallery?

Use CountRows(Filter(Gallery.AllItems, CheckboxName.Checked)) in a text label. If you track picks in a collection, CountRows(colSaPicked) gives the same number.

How do I set a checkbox value in a Power Apps gallery?

Set the row checkbox’s Default (Checked on newer builds) to a formula that returns true or false, such as ThisItem.ID in colSaPicked.ID. The box re-evaluates whenever the collection changes.

Why does Select all stay checked after I uncheck one row?

Because the header box only reads a variable that nothing updates. Drive its Default from the selection instead, so it turns false on its own when one row is cleared.

Does Select all check every item in a large SharePoint list?

No. Gallery AllItems holds only loaded rows, 100 at first in my test. Microsoft’s gallery control reference notes AllItems can be smaller than Items. See also the modern checkbox reference.