In this PowerApps Tutorial, We will discuss what is PowerApps CountRows function, What is its syntax. Also, By taking some simple scenarios, We will see how a user can use it in the PowerApps.
Also, We will discuss about these below topics that are related to PowerApps CountRows() function as:
- PowerApps CountRows function
- PowerApps CountRows function Syntax
- PowerApps countrows filter
- PowerApps countrows delegation sharepoint
- PowerApps countrows sharepoint list
- PowerApps countrows alternative
- PowerApps countrows gallery or PowerApps count rows in gallery
- PowerApps countrows datatable
- PowerApps countrows collection
PowerApps CountRows function
- PowerApps CountRows function helps to count the total number of items or records either in a table, SharePoint list, or a gallery control.
- This PowerApps CountRows function always returns a number value.
- If you use CountRows functions with filters, then there will be a 50K delegation limit. There is no hard limit on the CountRows function when extracted directly from the data source because of the cached count that Dataverse keeps.
- When you are using the PowerApps CountRows() function without filtering, then the count might not be 100% accurate, because the cached count updates periodically.
PowerApps CountRows function Syntax
Below represents the syntax for PowerApps CountRows function:
CountRows( Table )
Where,
Table = It is required. Specify the table that you needs to be count all the records within it.
PowerApps countrows filter
In this example, We will see how to work with PowerApps CountRows() function including the Filter function.
- The below screenshot represents a SharePoint list named Project Details. This list has these many below columns:
- Title (By default it is present in the SharePoint list)
- Employee First Name (Single line of text)
- Employee Last Name (Single line of text)
- Employee Job (Choice column)
- Client (Choice column)
Check out, PowerApps StartsWith and EndsWith Functions
PowerApps countrows filter with SharePoint Choice Column
- Here we will see how to work with the PowerApps count rows filter including SharePoint Choice Column. In the above screenshot, you can see there is a Choice column named Client that has some choice values.
- Now I would like to count the total number of specific choice-value using the PowerApps CountRows function.
- To do so, Insert a Label control and apply this below formula on its Text property as:
Text = "Total Number of Filtered Items:" & CountRows(
Filter(
'Project Details',
Client.Value = "TSInfoTechnologies"
)
)
Where,
- “Total Number of Filtered Items:” = This is the text that will display in the label control
- ‘Project Details’ = SharePoint List Name
- Client.Value = SharePoint Choice column and you need to specify the choice column with the value function
- “TSInfoTechnologies” = Specify one choice-value that you want to count
- Save and Publish the app. Then reopen the app again. You can see the total number of choice values in the label control as shown below.
You may also like, Power Apps Len Function.
PowerApps countrows filter with SharePoint Single Line Text Column
- Here we will see how to work with the PowerApps count rows filter including SharePoint Single line of text Column. In the above screenshot, you can see there is a Single line column named Employee First Name.
- Now I would like to count the total number of specific filter items (with a single line column) using the PowerApps CountRows function.
- To do so, Insert a Label control and apply this below formula on its Text property as:
Text = "Total Number of Filtered Items:" & CountRows(
Filter(
'Project Details',
'Employee First Name' = "Preeti"
)
)
Refer to the below screenshot.
- Save and Publish the app. Then reopen the app again. You can see the total number of specified values in the label control as in the below screenshot.
PowerApps countrows delegation sharepoint
- Suppose in your data source, there is a total of 5000 items or records. Here, I want to display all the items (from the Data source) on the PowerApps screen.
- But there is a limitation in the PowerApps app where it always returns only 500 items (from the data source). This is known as PowerApps Delegation.
- When you will create a PowerApps application, most of the time you can see there will be a warning sign on the formula, if the function is not delegable. The warning message states that: “Delegation warning: The “filter” part of this formula might not work correctly on large data sets.”
- Always remember, 500 is the PowerApps Default limit. We can extend this limitation from 500 to 2000 by using the following instructions:
- Open your PowerApps app
- Go to the File tab and then Settings
- Select on Advanced Settings
- Set the value to 2000 in the Data row limit for non-delegable queries
- In some cases, the 2000 record limit can satisfy the requirement. But most of the cases, also may not satisfy because maybe the data source has more than 2000 items (as in my data source it has 5000 records).
- So in this case, We will do another thing i.e. PowerApps Collection.
- If you will create a collection, then there will be no delegation limit and one collection can hold at most 10K items or records.
- At first, you need to save the data for collection. Let’s take an example. Set the below formula on the OnStart property of your app:
OnStart = ClearCollect(collectionname,SharePointlistname)
- Next, Use this collection to your specific requirement as like:
CountRows(colletionname)
PowerApps countrows sharepoint list
In this example, We will see how we will work PowerApps countrows function with a SharePoint list.
- The below screenshot represents a SharePoint List named Travel Details. This list has these below columns:
- Traveller (By default it is Title column)
- Source (Choice column)
- Travel Start Date (Date column)
- Here I want to count total number of Travellers that belongs to Bangalore only. To do so, follow these below things.
- On the PowerApps screen, I have a gallery control with the specific SharePoint List Data source (Travel Details). Here, you can see there is a total three number of travellers that belong to Bangalore only.
- To count the values, Insert a Label control and apply this below formula on its Text property as:
Text = "Total count of Travellers that belongs to Bangalore: " & CountIf(
'Travel Details',
Source.Value = "Bangalore"
)
Where,
- ‘Travel Details’ = SharePoint List Name
- Source = SharePoint Choice column name
Refer to the below screenshot.
- Once you will save and preview the app, then you can see the value will be 3 that will display in the label control as shown in the above screenshot.
You may also like, How to build multilingual app in PowerApps.
PowerApps countrows gallery or PowerApps count rows in a gallery
Here we will discuss how we can work with the PowerApps CountRows function in Gallery control.
- On the PowerApps screen, I have a gallery control (Blank Vertical) with these below items as:
Items = ["One","Two","Three"]
- Now I would like to count the total number of records that are present in the gallery control. Also, I want to count the total number of records (each individual value) that are selected by the user.
- To count the total number of items from the gallery, you can apply this below formula on Label’s Text property as:
Text = "Total Items in the Gallery: " & CountRows( Gallery1.AllItems)
Where,
- “Total Items in the Gallery: “ = This is the text that I want to display in the Label control
- Gallery1 = Gallery control name
- Save and Preview the app. Then you can see there are total four number of records present in the gallery control as like the below screenshot.
- Similarly, To count the total items where the radio value is One, apply this below formula on Label’s Text property as:
Text = "Total Items where value is One: " & CountRows(Filter( Gallery1.AllItems, Radio1.Selected.Value = "One" ) )
Where,
Radio1 = Radio control name
- Once you will save and preview the app, you can see there are two records where the value is One.
- To count the total items where the radio value is Two, apply this below formula on Label’s Text property as:
Text = "Total Items where value is Two: " & CountRows(Filter( Gallery1.AllItems, Radio1.Selected.Value = "Two" ) )
- Once you will save and preview the app, you can see there are total three records where the value is Two.
- To count the total items where the radio value is Three, apply this below formula on Label’s Text property as:
Text = "Total Items where value is Three: " & CountRows(Filter( Gallery1.AllItems, Radio1.Selected.Value = "Three" ) )
- Once you will save and preview the app, you can see there is only one record where the value is Three.
This is how to count rows on a PowerApps gallery control.
You may like, PowerApps Value Function.
PowerApps countrows datatable
- In the below screenshot, you can see there is a PowerApps Data table that holds the SharePoint list data source. It has a total five number of records.
- Now I would like to count the total number of rows that are present inside that specific Data table. That’s why I applied this below formula on Label’s Text property as:
Text = CountRows(DataTable1)
Where,
DataTable1 = Data table name
- But the problem is, When I applied this formula, it gives me an error as: “Invalid argument type (Control). Expecting a Table value instead. The function ‘CountRows’ has some invalid arguments.” Refer to the below screenshot.
- The error I am getting because of passing the data table name to the CountRows function does not exist.
- The solution to this problem is, you need to provide the data source name rather than the data table name. You can find this by viewing the properties of your data table, and going to the Data section.
- To do so, I applied this below formula on Label’s Text property as:
Text = CountRows(Classes)
Where,
Classes = SharePoint list name
- Once you will save and publish the app, the label will display the total number of items that are having the specified data source.
This is how we can use the PowerApps countrows() function to count rows in a data table.
Check out, How to Create CSV in SharePoint using PowerApps and Power Automate.
PowerApps countrows collection
Here we will see how to work PowerApps Collection using the Countrows function. Lets take a simple scenario.
- There is a PowerApps Collection named MyListCollection where the items are retrieved from the SharePoint list data source. There are a total five number of records in the PowerApps Collection.
- Here I would like to count the total number of records that are present in the PowerApps Collection (MyListCollection) and that will display in the Label control.
- To do so, apply this below formula on Label’s Text property as:
Text = "Total Number of Items in Collection: " & CountRows(MyListCollection)
Where,
- “Total Number of Items in Collection: “ = This is the text that will display in the label control
- MyListCollection = Specify the PowerApps collection name
- Once you will save and preview the app, you can see the total number of records in the label control as in the below screenshot.
This is how to count rows in a PowerApps collection using countrows() function.
Also, you may like these below PowerApps Tutorials as:
- PowerApps Count Function with Examples
- PowerApps CheckBox – How to use
- PowerApps First, FirstN, Last, and LastN function with examples
- PowerApps LastSubmit() with Examples
- PowerApps AddColumns Function with Examples
- PowerApps Patch Function with examples
- PowerApps ForAll Function with examples
- PowerApps if statement with examples
- PowerApps Replace Function with examples
- PowerApps Employee Directory
- PowerApps Pen input control (PowerApps signature)
- PowerApps SharePoint Lookup Column + PowerApps Dropdown Example
In this PowerApps Tutorial, We discussed what is PowerApps CountRows function, What is its syntax. Also, By taking some simple scenarios, We saw how a user can use it in the PowerApps.
Also, We discussed about these below topics that are related to PowerApps CountRows function as:
- PowerApps CountRows function
- PowerApps CountRows function Syntax
- PowerApps countrows filter
- PowerApps countrows delegation sharepoint
- PowerApps countrows sharepoint list
- PowerApps countrows alternative
- PowerApps countrows gallery or PowerApps count rows in gallery
- PowerApps countrows datatable
- PowerApps countrows collection
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com
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.
lovely cocepts clearance
Excellent article and great workaround for counting rows in a data table. That helped me while struggling with that error. Thanks.
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