Are you interested in learning how to count all rows/records in the Power Apps gallery control? This Power Apps tutorial will teach all the information about the count rows in Power Apps gallery control.
Here, we will discuss how to get the number of rows in a Power Apps gallery using ‘AllItemsCount’. Then, I will show you how to display the total gallery row count on a Text label.
Additionally, we will learn the Power Apps count rows in the gallery control using the Filter() function and Power Apps gallery count rows over 100 records.
Count Rows in Power Apps Gallery Control
With a simple example, let’s see how to get the total row count in a Power Apps gallery control.
Example:
I have a SharePoint Online list named “Project Tracker“. This list contains the below fields.
Column Name | Data Type |
Project Name | Default single line of text column |
Description | Multiple lines of text |
Project Status | Choice |
Start Date | Date and time |
End Date | Date and time |
Refer to the below screenshot:
In Power Apps, there is a Gallery control that is connected to my SharePoint list. Now, I want to count all rows in a gallery control and display the row count on a text label as in the screenshot below.
To work around this example, follow the steps below. Such as:
1. Open Power Apps with your respective Microsoft credentials -> Create Power Apps Canvas app and connect it to the respective SharePoint Online site like below.
2. Insert a Blank gallery control and set its Items property as:
Items = 'Project Tracker'
3. Next, Add Text labels inside the gallery to retrieve the records from the SharePoint list, as shown below.
Text = ThisItem.Title
Text = ThisItem.Description
Text = ThisItem.'Project Status'.Value
Text = ThisItem.'Start Date'
Text = ThisItem.'End Date'
Refer to the below image:
3. Now, Insert another Text label under the Gallery control and set its Text property to the code below.
Text = $"{gal_Projects.AllItemsCount} Items"
Where,
- gal_Projects = Power Apps Gallery Name
- AllItemsCount =This property is used to get all gallery record’s count in Power Apps
4. Save, Publish, and Preview the app. The Power Apps Text input displays total row counts based on the gallery records, as in the screenshot below.
This is how to get the total row count in the Power Apps gallery control.
Power Apps count Rows in Gallery with Filter
Here, I will show you how to get the Power Apps gallery rows/items count using the Filter() function.
Example:
Here, I will also take the same SharePoint list [Project Tracker] for this example. Now, I want to count all gallery rows based on the SharePoint list choice field [Project Status].
Whenever a user opens a Power Apps Gallery control, it will display only the “Completed “project’s record count, as shown below.
To achieve it, follow the below steps.
1. On the Power Apps Screen -> Select a Text label and set its Text property to the code below.
Text = CountRows(
Filter(
gal_Projects.AllItems,
'Project Status'.Value = "Completed" //You can also change the choice field value
)
)
Where,
- CountRows() = This Power Apps CountRows() function counts the number of records in a table.
- Filter() = This function is used to find a set of records that match one or more criteria
- gal_Projects.AllItems = Power Apps Gallery all items/records
- ‘Project Status’.Value = SharePoint list choice field value
2. Save, Publish, and Preview the app. The Text label will filter and display the records/rows count based on the SharePoint list choice value [Completed] as shown below.
This is how to filter a Power Apps gallery count rows.
Power Apps Gallery Count Rows Over 100 Records
In the last, we will see how to get the Power Apps gallery row count over 100 records with a simple scenario.
Scenario:
- I have a SharePoint Online list, i.e., [User Subscription Details], which contains 2500 records with different fields as in the screenshot below.
- Now, I will show these records on a Power Apps gallery and get the total row count in the text label. However, the Power Apps gallery will only load the initial 100 records until I scroll down to the bottom.
Refer to the below screenshot:
- Also, when the user starts scrolling after 100 records, the gallery row count will be higher, but it is not right to count the gallery rows as below.
- To resolve this issue, follow the below Text label’s Text property code:
Text = $"{gal_SubscriptionRecords.AllItemsCount}{If(
First(
Sort(
'User Subscription Details',
ID,
SortOrder.Descending
)
).ID <> Last(gal_SubscriptionRecords.AllItems).ID,
"+"
)} Items"
Where,
- gal_SubscriptionRecords = Power Apps Gallery Control
- ‘User Subscription Details’= SharePoint Online List
- “+” = Use this symbol when the gallery row count is unknown. But once you get to the last row, it will disappear
- Now, when the user scrolls down to the last row, the text label will display the actual row count without the ‘+’ symbol.
This is all about the Power Apps gallery count rows over 100 records.
Conclusion
I hope this Power Apps tutorial taught in detail information about the count rows in Power Apps Gallery control, including:
- How to get the number of rows in a Power Apps gallery using ‘AllItemsCount’
- Power Apps count rows in the gallery control using the Filter() function
- Working with Power Apps gallery count rows over 100 records
You may also like the following tutorials:
- Power Apps Sort Gallery By Calculated Field
- How to Sort Power Apps Gallery By Month
- How to Select Multiple Items in Power Apps Gallery Control?
- How to Add New Row in Power Apps Gallery Control?
- Customize a Power Apps Gallery Layout
- How to Display SharePoint List Items in PowerApps Gallery?
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