Power Apps CountRows Function [Including the Delegation Fix]

CountRows looks like one of the simplest functions in Power Apps — until it silently gives you the wrong number. If your SharePoint list has 1,200 records but CountRows keeps returning 500, you’ve hit the delegation limit. And if you tried the “just use a Collection” workaround — surprise, that doesn’t fix it either.

In this tutorial, I’ll walk you through every real-world CountRows scenario with working formulas, show you where it breaks, and give you the actual fix. I’ve also included a quick decision tree so you know when to use CountRows versus CountIf versus CountA versus Count — because picking the wrong one is what causes most of the confusion.

Here’s what we’ll cover:

  • What CountRows does and its syntax
  • How to use CountRows with Filter (Choice and Text columns)
  • The delegation problem and how to actually fix it
  • CountRows with a SharePoint list
  • CountRows in a Gallery
  • The Data Table error (and what to do instead)
  • CountRows on a Collection (and the 500-row trap)
  • CountRows vs CountIf vs CountA vs Count — when to use which
  • Common errors and how to fix them
  • FAQs

What Is Power Apps CountRows Function?

CountRows counts the total number of records in a table, collection, or gallery. That’s it. It always returns a number.

Syntax:

CountRows( Table )

The Table argument is required. You pass in a data source, collection, or gallery reference, and it gives back the total row count.

A few things worth knowing upfront:

  • CountRows does not evaluate any conditions — it just counts everything in what you pass it
  • When used directly on a data source (like a SharePoint list), it reads from a cached count, which means it can be slightly inaccurate if your list is constantly changing
  • When combined with Filter(), the 500/2000 row limit kicks in, and you’ll almost certainly get a wrong number for large lists
  • The reliable alternative for accurate counts on large lists is CountIf(DataSource, true) — more on this below.

Power Apps CountRows with Filter — Counting Specific Items

This is the most common use case. You have a SharePoint list and want to count how many items match a certain condition.

Example 1: Counting by a Choice Column

Say you have a SharePoint list called Project Details with a Choice column named Client. You want to count how many records have the client value “TSInfoTechnologies”.

Put this formula on a Label’s Text property:

"Total Matching Items: " & CountRows( Filter( 'Project Details', Client.Value = "TSInfoTechnologies" ) )
Power Apps CountRows with Filter

A couple of things to note here:

  • For Choice columns, always use .Value — so it’s Client.Value, not just Client
  • This formula will give a delegation warning for large lists. If your list has more than 500 records (or 2000 if you’ve bumped up the limit), switch to CountIf instead:
CountIf( 'Project Details', Client.Value = "TSInfoTechnologies" )
power apps countrows of sharepoint list by a choice column

Example 2: Counting by a Text Column

If you want to count rows where a single-line text column matches a value — for example, counting all employees whose first name is “Preeti”:

"Total Matching Items: " & CountRows( Filter( 'Project Details', 'Employee First Name' = "Preeti" ) )

Again, for large lists, replace CountRows(Filter(...)) with CountIf('Project Details', 'Employee First Name' = "Preeti").

power apps countrows function with filter by a text column

Personal note: In every client project I’ve worked on, I default to CountIf rather than CountRows + Filter whenever the data source is SharePoint. It’s cleaner, less likely to hit the row limit, and you avoid the delegation warning. The only time I use CountRows directly is on Collections or on gallery’s .AllItems.

The Delegation Problem — Why CountRows Returns 500 (or 2000) in Power Apps

This is the section most tutorials gloss over, and it’s the source of so much confusion.

When your Power Apps canvas app runs a non-delegable query, it downloads only the first 500 records from the data source and performs all the work locally. So if your SharePoint list has 5,000 items, your app only ever sees 500 of them — and CountRows returns 500, not 5,000.

You can increase this limit from 500 to 2000:

  1. Open your app in Power Apps Studio
  2. Go to Settings (or File > Settings in older versions)
  3. Select General
  4. Under Data row limit for non-delegable queries, set the value to 2000

But — and this is the important bit — 2000 is the maximum. You cannot go higher. So if your list has 10,000 records and you need an accurate count, the row limit setting won’t help.

power apps data row limits for delegation

The Power Apps ClearCollect “Fix” That Doesn’t Work

You’ve probably seen this advice online (including, honestly, in older versions of my own tutorials):

ClearCollect(MyCollection, 'My SharePoint List')
CountRows(MyCollection)

The idea is that collections don’t have delegation limits. The problem is that ClearCollect itself still only loads the first 500 (or 2000) rows from the data source into the collection. So your collection has 500 rows, and CountRows dutifully returns 500. You’ve just hidden the problem.

One of my readers, Benwishh, pointed this out in the comments, and they were absolutely right. So let me give you the actual fix.

The Actual Fix: Power Apps CountIf with True

For getting an accurate total count of all records in a SharePoint list, use:

CountIf( 'Your SharePoint List', true )

This is delegable — it pushes the count calculation to SharePoint’s server rather than pulling records down to the app. It works for lists up to 50,000 records.

For DataverseCountRows('Your Table') Itself is delegable and reads from a cached count. If you need a fully precise real-time count on Dataverse, use:

CountIf( 'Your Table', true )

⚠️ Important: CountIf for SharePoint is not delegable when you add a filter condition (like CountIf('List', Status = "Active")). That will still hit the row limit. The true trick works only for total counts. For filtered counts on large SharePoint lists with more than 2000 records, you’ll need a Power Automate flow to get the count from the SharePoint REST API.

Power Apps CountRows With a SharePoint List

Let me walk through a clean, practical example.

You have a SharePoint list called Travel Details with a Source choice column. You want to count how many travellers are from Bangalore.

For lists under 2000 records, this works fine:

CountRows( Filter( 'Travel Details', Source.Value = "Bangalore" ) )
Power Apps CountRows with a SharePoint List

For lists over 2000 records, use:

CountIf( 'Travel Details', Source.Value = "Bangalore" )

Wait — I just said CountIf with a filter condition hits the row limit on SharePoint. Both of these technically have delegation warnings for Choice column filters on large lists, because SharePoint delegation for Choice columns is limited. If your list regularly grows beyond 2,000 items and you need an accurate filtered count, the cleanest production approach is to call a Power Automate flow that uses the SharePoint $count REST endpoint.

For most real-world apps with lists under 2,000 records, CountIf With the condition, it works perfectly.

This one is genuinely straightforward and doesn’t have delegation issues — because you’re counting what’s already loaded in the gallery, not querying a data source.

To count all items in a Power Apps gallery:

"No.of Items: "&CountRows(Gal_ProjectDetails.AllItems)
Power Apps CountRows in a Gallery

To count items in a gallery that match a specific condition (say, items where a project status is “On Hold”):

"No.of On Hold Projects: "&CountRows( Filter( Gal_ProjectDetails.AllItems,ProjectStatus.Value ="On Hold") )
Power Apps CountRows in a Gallery with Filter Function

This counts only the visible/loaded gallery rows that match your condition. It’s useful for building summary stats below a filtered gallery — like “Showing X of Y results.”

One thing to be aware of: Gal_ProjectDetails.AllItems Only reflects rows that have been loaded into the gallery. If your gallery uses virtual scrolling with a large dataset, it may not load all records. For a reliable count of all matching source records, use CountIf directly on the data source.

Power Apps CountRows with a Data Table — The Error Explained

This is one of the most-searched issues around CountRows, so let me clear it up properly.

If you try to put this on a label:

CountRows( DataTable1 )

You’ll get this error:

“Invalid argument type (Control). Expecting a Table value instead.

Power Apps CountRows with a Data Table

The reason is that Power Apps DataTable is a control, not a table. CountRows expects a table or data source, not a UI component.

The fix: pass in the data source name that powers the Data Table, not the Data Table control itself. Check your Data Table’s Items property to see what data source it’s connected to — for example, a SharePoint list called “Classes”:

CountRows( 'Project Details' )
Power Apps countrows function with a data table control

But this counts the total records in the “‘Project Details'” list, not the rows currently visible in your filtered Data Table. If your Data Table shows filtered results, those two numbers can differ significantly.

To count the rows actually shown in a filtered Data Table, you need to replicate the same filter condition:

CountRows( Filter( 'Project Details', Status = "On Hold" ) )

Power Apps CountRows on a Collection

If you’ve already created a Power Apps Collection (for example, after loading data with ClearCollect), you can count its rows like this:

CountRows( colProjectDetails)
Power Apps CountRows on a Collection

This is instant and has no delegation issues — collections live in memory. The count you get back is, however, the number of rows actually in the collection.

Just remember what I mentioned earlier: if your collection was loaded from SharePoint using ClearCollect, it may contain only 500 or 2000 rows, depending on your row limit setting. The CountRows result is correct for the collection — it’s the collection loading step that may be incomplete.

Which Power Apps Count Function Should You Use? (Decision Guide)

This is the question I get most often. Here’s how I think about it:

Use CountRows when:

  • You’re counting all items in a Collection
  • You’re counting Gallery.AllItems
  • You need the total count of a Dataverse table (it’s delegable there)
  • Your dataset is small and fits within the row limit

Use CountIf(Source, true) when:

  • You need an accurate total count from a SharePoint list (any size)
  • You want to bypass the cached Dataverse count for precision

Use CountIf(Source, condition) when:

  • You need a conditional count, and your list is under ~2,000 records
  • Your data source is Dataverse (fully delegable for CountIf)

Use CountA when:

  • You want to count non-blank values in a specific column
  • Example: CountA(Employees.Email) counts only rows where Email isn’t blank

Use Count when:

  • You’re counting numeric values in a column
  • Example: Count(Sales.Amount) counts rows where Amount has a numeric value
FunctionWhat It CountsDelegable (SharePoint)?Best For
CountRows(Table)All rowsPartial (cached)Collections, Galleries
CountIf(Source, true)All rowsYesLarge SharePoint lists, accurate totals
CountIf(Source, condition)Matching rowsPartialConditional counts under 2000 rows
CountA(Table.Column)Non-blank column valuesNoChecking data completeness
Count(Table.Column)Numeric column valuesNoNumeric summaries

Common Errors and How to Fix Them

Here’s a checklist of the issues I see come up most often:

  • CountRows returns 500 → You’ve hit the default row limit. Either increase it to 2000 in Settings, or switch to CountIf(Source, true) for an accurate count
  • CountRows returns 2000 → You’ve set the row limit to 2000, but your list has more records. Use CountIf(Source, true) instead
  • “Invalid argument type (Control)” error → You passed a Data Table control name. Use the underlying data source name instead
  • ClearCollect + CountRows still returns 500 → The collection itself was only loaded with 500 rows. This doesn’t bypass delegation at the loading stage
  • CountIf with a filter condition still gives wrong results on large lists → CountIf with conditions isn’t delegable for all SharePoint column types. Choice column filters have limited delegation support. Use Power Automate for filtered counts on very large lists
  • Delegation warning on CountRows + Filter → Expected behaviour. Switch to CountIf(Source, condition) to reduce (though not always eliminate) the warning
  • Count on a column returns 500 → Count and CountA are not delegable at all. They always hit the row limit

Conclusion

I hope you found this article helpful. In this guide, we learned how to use the CountRows function in Power Apps across different scenarios, including filters, SharePoint lists, galleries, data tables, and collections. We also looked at real examples to understand how CountRows works when counting specific records based on conditions, such as text or choice columns.

We also discussed the delegation issue, which is one of the most common problems developers face when using CountRows with large data sources. Additionally, we explained why some common fixes may not always work and how to handle record counting more correctly. If you run into any issues using these approaches, feel free to leave a comment, and I’ll be happy to help.

Also, you may like:

Frequently Asked Questions

Is CountRows delegable in Power Apps?

It depends on the data source. For Dataverse, CountRows is delegable and reads a cached count. For SharePoint, it returns the cached count, but it can be inaccurate. Use CountIf(Source, true) for a precise, delegable count from SharePoint.

What’s the difference between CountRows and CountIf?

CountRows counts every row in a table with no conditions. CountIf counts only rows that match a condition you specify. If you want total records, use CountRows (or CountIf(Source, true) for large lists). If you want filtered counts, use CountIf with a condition.

Why does CountRows show 500 instead of the actual number?

Because Power Apps only pulls the first 500 records locally for non-delegable queries. To get the real total, use CountIf('Your List', true).

Can I use CountRows on a filtered gallery?

Yes: CountRows(Filter(Gallery1.AllItems, YourCondition)). This counts filtered rows from what’s loaded in the gallery.

What’s the maximum record count CountIf can handle?

CountIf has a 50,000 record delegation limit. If your list exceeds that, you’ll need a Power Automate flow using the SharePoint REST API’s $count parameter.

Does CountRows work on Dataverse?

Yes, and better than on SharePoint. CountRows on a Dataverse table is delegable and returns a cached count. For a real-time, precise count, use CountIf('Table', true).

Why do I get an error when I use CountRows on a Data Table control?

Because CountRows expects a data source (a table), not a UI control. Use the name of the data source (e.g., your SharePoint list name) instead of the Data Table control name.

4 thoughts on “Power Apps CountRows Function [Including the Delegation Fix]”

  1. Please delete the “PowerApps countrows datatable” section in that you are not counting the number of rows in the Data table you are counting the number of rows in the underlying list. That is useless if you want to how many rows are in shown in your actual table (search/filtered). Also there is a delegation issue using the process you have described.

  2. The Collection trick doesn’t work. The ClearCollect(collectionname,SharePointlistname) also only stores the first 500 rows into the collection. So the Countrows function on the collection will also only return 500. You just get rid of the delegation warning but you don’t solve the problem

Leave a Comment

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Live Webinar

Quiz App Using SharePoint Framework (SPFx)

Learn to built a complete Quiz Management solution that enables admins to create and manage quizzes, categories, questions, and settings with an easy automated setup process in SharePoint. It also includes an interactive quiz experience for users and a powerful dashboard to track participation, analyze results, and view detailed performance reports with charts and answer insights.

📅 2nd June 2026 – 10:00 AM EST | 7:30 PM IST

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App