Tutorials/Power Apps/Efficiently Count Gallery Rows in Power Apps: The AllItemsCount Property
Power Appsintermediate

Efficiently Count Gallery Rows in Power Apps: The AllItemsCount Property

Learn how to use the AllItemsCount property for fast, client-side row counting and how to handle large datasets properly.

NA
Narmer Abader
@narmer · Published June 3, 2026

Displaying the number of items inside a gallery is a common requirement in canvas apps. Many makers reach for the CountRows function, but it can introduce delegation issues and unnecessary network calls. The gallery’s built-in AllItemsCount property provides a faster, client‑side way to get the count of records currently loaded in the gallery. In this article we’ll explore how to use it, when it shines, and how to work around its limitations when dealing with large datasources.

Understanding AllItemsCount

AllItemsCount is a property available on any gallery control (vertical, horizontal, flexible height, etc.) that returns the number of items the gallery has loaded into memory. It doesn’t re‑query the datasource; it simply reads an internal counter that Power Apps maintains as the gallery renders.

Prerequisite

This property is available from Power Apps version 3.23051.19 or later. Check your environment’s version before using it in production.

Scenario: Task Manager Dashboard

Imagine a task management app connected to a SharePoint list called Tasks. The list contains thousands of items, and you want a gallery to display active tasks. A label above the gallery should show something like “Showing 20 of 150 tasks” or simply “20 tasks” when the list is fully loaded.

To avoid confusion, we’ll use the following controls:

  • Gallery: gal_TaskList (bound to the Tasks list)
  • Label: lbl_TaskCount (placed above the gallery)

Step‑by‑Step Implementation

Set the gallery’s Items property to the datasource and apply any filter you need.

Filter(Tasks, Status = "Active")

2. Use AllItemsCount in a Label

For a basic count of visible items, set the label’s Text property:

powerfxLabel showing the loaded item count
"Tasks: " & gal_TaskList.AllItemsCount

The label will update automatically as the gallery loads more items during scrolling.

3. Combine with Total Count (When Delegation Works)

If your datasource supports delegation for CountRows, you can show both the loaded count and the total:

powerfxLabel showing loaded vs. total count
$"Showing {gal_TaskList.AllItemsCount} of {CountRows(Tasks)} tasks"

Be careful: CountRows(Tasks) may not be delegated for some connectors (e.g., SharePoint), causing it to return only the first 500 items. In that case the total shown will be inaccurate.

Handling Large Datasources That Paginate

For non‑delegable datasources (or when CountRows can’t return the real total), the gallery only loads a chunk of records—often 100 at a time. AllItemsCount reflects only the loaded chunk, not the total dataset.

To indicate that more records exist, you can compare the last item’s ID in the gallery with the maximum ID in the datasource. If they differ, append a “+” to the count.

powerfxLabel text that appends + when more items are pending
$"{gal_TaskList.AllItemsCount}" & If(
  Not IsEmpty(gal_TaskList.AllItems),
  If(
      First(Sort(Tasks, "ID", SortOrder.Descending)).ID <> Last(gal_TaskList.AllItems).ID,
      "+",
      ""
  ),
  ""
) & " tasks"

How it works:

  • First(Sort(Tasks, "ID", SortOrder.Descending)) gets the highest ID from the datasource.
  • Last(gal_TaskList.AllItems).ID gets the ID of the last item currently in the gallery.
  • If they don’t match, there are more records to load, so "+" is added.

When the user scrolls to the bottom and the gallery loads all records, the IDs will match and the label shows the exact total.

Performance Note

Using First(Sort(...)) and Last(...) in this way involves additional queries. For very large lists, consider storing the total count in a separate collection that you refresh less frequently.

Performance Benefits of AllItemsCount

  • No extra network request – The count is read from memory, not from the datasource.
  • No delegation riskAllItemsCount is always accurate for what the gallery has loaded.
  • Works with filters – If the gallery’s Items includes a filter or search, the count reflects only the filtered set.
  • Instant updates – When the gallery changes (pagination, filtering, sorting), the property updates synchronously.

Common Mistakes and Troubleshooting

MistakeSolution
Using AllItemsCount on a non‑gallery controlOnly galleries expose this property.
Expecting it to return the total dataset countIt returns only the currently loaded items. Use the workaround above if you need to hint at a larger dataset.
Forgetting the version requirementIf you see no property in IntelliSense, update your Power Apps environment.
Trying to set the property (read‑only)AllItemsCount can only be read, never written.
Basing logic on AllItemsCount when the gallery is emptyCheck IsEmpty(gal.AllItems) first to avoid errors on Last(...).

Final Recommendation

Use AllItemsCount whenever you need to display the number of items that a gallery is currently showing. It’s faster and simpler than CountRows(gal.AllItems) and avoids delegation pitfalls. For scenarios where you must also indicate unloaded records, combine the property with a lightweight check such as the ID‑matching pattern shown above.

Adopting this approach makes your apps more performant and your code easier to maintain.

References