web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / CountRows showing inva...
Power Apps
Suggested Answer

CountRows showing invalid count

(1) ShareShare
ReportReport
Posted on by 144
I have a datasource wuith count 3600 but the below code shows only 2000.
 
May i know how to get the exact count of datasource?
 
"Records: "&CountRows(Gallery1_17.AllItems)
 
I have the same question (0)
  • Suggested answer
    11manish Profile Picture
    3,849 Super User 2026 Season 2 on at
    Avoid using:

    CountRows(Gallery1_17.AllItems)
     
    to determine the total number of records. Instead, count the data source itself (or the same filtered query) whenever possible. If your data source is SharePoint, the 2,000-record result is a delegation limitation, and the most reliable way to get the true count of 3,600 records is to use Power Automate, the SharePoint REST API, or another server-side mechanism.
  • Haque Profile Picture
    4,004 Super User 2026 Season 2 on at
    Hi @Poweruser32490,
     
    It would have been better if you could mention you data source (Dataverse, SP, SQL server?).
     
    If your data source uses an auto-incrementing ID column and you rarely delete items, the largest ID number in the system naturally represents your total count. Because Max can be a delegable function, you can retrieve the highest ID directly from the server. 
    Example: Set your label/text to:
    First(Sort(datasrouce,ID, SortOrder.Descending)).ID
    Other way what we can do is In Power Apps, call the flow using a variable:
    UpdateConext({VarTotalCount: FlowName.Run()})
    Where flow gets the count of your data source. Please note that, FlowName should be replaced with your flow name.
     
     
    References:
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
     
  • WarrenBelz Profile Picture
    156,271 Most Valuable Professional on at
    You actually have two issues here - assuming that you are using SharePoint as a data source, it has already been mentioned that you will get more than 2,000 with the CountRows function, however an additional issue with a Gallery is that if the Items are a Delegable query (potentially exposing the full record list), the user would need to scroll down through 36 batches of 100 items to see all of the records. I therefore assume that the Items of your gallery are a collection ?
     
  • Poweruser32490 Profile Picture
    144 on at
    Hi @WarrenBelz,
     
    When i apply filters, the Record count label also should get updated. If i use CountRows(Datasource), those count wont get updated. Also there is a bit of slowness since there are 3600 records. May i know how to mitigate this slowness?
     
    Gallery Items Property
    With(
        {
            _activerequests: SortByColumns(
                Filter(
                    'Data Source',
                    (Len('Process Type CB'.Selected.Value) = 0 || ChoiceProcessType.Value = 'Process Type CB'.Selected.Value) && (Len('Employee Type CB'.Selected.Value) = 0 || ChoiceResourceType.Value = 'Employee Type CB'.Selected.Value) && (Len('Region CB'.Selected.Value) = 0 || Region_New = 'Region CB'.Selected.Value) && (StartsWith(
                        FirstName,
                        SearchBox.Text
                    ) || StartsWith(
                        Title,
                        SearchBox.Text
                    ) || StartsWith(
                        JobTitle_New,
                        SearchBox.Text
                    ) || StartsWith(
                        Region_New,
                        SearchBox.Text
                    ))
                ),
                "Modified",
                SortOrder.Descending
            )
        },
        SortByColumns(
            _activerequests,
            varsortcolumn,
            varsortdirection
        )
    )
     
    CountRows Label Text property
    "Records: "&CountRows(Gallery1_17.AllItems)
     
  • WarrenBelz Profile Picture
    156,271 Most Valuable Professional on at
    Two things now that I have seen your Gallery Items
     
    You will only ever get 2,000 records with that filter as With() is a "local" function - a temporary Table Variable which is effectively a Collection and the output (the list can be of any size) is limited to your Data Row Limit. The lack of full Delegation capacity is caused by your need to have variable Sort criteria, which is not supported by Delegation.
     
    If your Items were this
    SortByColumns(
       Filter(
          'Data Source',
          (
             Len('Process Type CB'.Selected.Value) = 0 || 
             ChoiceProcessType.Value = 'Process Type CB'.Selected.Value
          ) && 
          (
             Len('Employee Type CB'.Selected.Value) = 0 || 
             ChoiceResourceType.Value = 'Employee Type CB'.Selected.Value
          ) && 
          (
             Len('Region CB'.Selected.Value) = 0 || 
             Region_New = 'Region CB'.Selected.Value
          ) && 
          (
             StartsWith(
                FirstName,
                SearchBox.Text
             ) || 
             StartsWith(
                Title,
                SearchBox.Text
             ) || 
             StartsWith(
                JobTitle_New,
                SearchBox.Text
             ) || 
             StartsWith(
                Region_New,
                SearchBox.Text
             )
          )
       ),
       "Modified",
       SortOrder.Descending
    )
    then the filter would be fully Delegable and you could potentially see all 3,600 items, however Delegable filters return in batches of 100 records, so the user would need to scroll to the bottom before they saw the full total count.
     
    Also using formulas in Labels like you have will experience a delay in resolving the result as the Gallery has to fully calculate the contents, including the very large proportion you cannot see without scrolling. You could try this in the Label (not sure it would be any faster, but at least it would not have to wait for the gallery) - you will still only get a maximum of 2,000 as CountRows is also not supported by Delegation.
    With(
       {
          _activerequests: 
          SortByColumns(
             Filter(
                'Data Source',
                (
                   Len('Process Type CB'.Selected.Value) = 0 || 
                   ChoiceProcessType.Value = 'Process Type CB'.Selected.Value
                ) && 
                (
                   Len('Employee Type CB'.Selected.Value) = 0 || 
                   ChoiceResourceType.Value = 'Employee Type CB'.Selected.Value
                ) && 
                (
                   Len('Region CB'.Selected.Value) = 0 || 
                   Region_New = 'Region CB'.Selected.Value
                ) && 
                (
                   StartsWith(
                      FirstName,
                      SearchBox.Text
                   ) || 
                   StartsWith(
                      Title,
                      SearchBox.Text
                   ) || 
                   StartsWith(
                      JobTitle_New,
                      SearchBox.Text
                   ) || 
                   StartsWith(
                      Region_New,
                      SearchBox.Text
                   )
                )
             ),
             "Modified",
             SortOrder.Descending
          )
       },
       CountRows(
          SortByColumns(
             _activerequests,
             varsortcolumn,
             varsortdirection
          )
       )
    )
     
    Please Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 410 Most Valuable Professional

#2
11manish Profile Picture

11manish 159 Super User 2026 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 89 Super User 2026 Season 2

Last 30 days Overall leaderboard