Do you know how to count all rows/records in the Power Apps collection? If not, no need to worry!
This Power Apps tutorial will teach complete information about how to count rows in Power Apps Collection, and also many more like:
- How to Count All Rows in Power Apps Collection manually
- Count All Rows/ Records in a Power Apps Collection from the SharePoint List
Power Apps Count Functions
PowerApps Count function helps count all records in a table. Also, it counts all items that satisfy a condition.
Refer to the below table:
Functions | Description | Syntax |
---|---|---|
Count() | It counts the number of items in a single-column table | Count(SingleColumnTable) |
CountA | It counts the number of items that are not blank in a table. This Powerapps CountA function includes an empty text (” “) in the count | CountA(SingleColumnTable) |
CountIf | This is the Power Apps function that helps to count the number of items in a table that are true for a logical formula | CountIf (Table, LogicalFormula) |
CountRows | This CountRows function helps to count the number of items or records in a table | CountRows(Table) |
NOTE:
All the above Powerapps Count functions (Count, CountA, CountIf, CountRows) always returns a number value.
How to Count Rows in Power Apps Collection
Now, we will see how to count all rows in the Power Apps collection with a simple example.
Example:
- Suppose there is a Power Apps collection that contains some records. I want to calculate the number of records or items in the Powerapps collections.
- The below screenshot represents the Power Apps Collection named “colBooks”. It has three different types of items. The number of records I want to show in a Text label control.
- I have applied the formula below on the Label’s Text property to do so:
Text = CountRows(BookCollection)
Where,
- CountRows() = This Power Apps CountRows() function helps to count the number of rows in a table/collection
- colBooks = Power Apps Collection Name
- Once you apply this formula, the number of collection items will be displayed in the label control, as shown in the screenshot below.
This is how we can count rows in the Power Apps Collection.
Count Rows in Power Apps Collection [From SharePoint List]
Here, we will discuss how to count all rows/records in the Power Apps collection from a SharePoint list with a simple example.
Example:
I have a SharePoint Online list named “Employee Onboarding” and this list contains the below fields.
Column Name | Data Type |
Employee ID | Default single line of text |
Employee Name | A single line of text |
A single line of text | |
Gender | Choice |
Joining Date | Date and time |
Refer to the below screenshot:
In Power Apps, there is a Data table control and a Text label. this data table displays all the collection records and the text label displays all rows/records count as in the screenshot below.
To do so, follow the below steps.
1. Open Power Apps -> Create Blank Canvas app and connect it to the respective SharePoint list as shown below.
2. Select the App object [from left navigation] and set its OnStart property to the code below.
OnStart = ClearCollect(
colEmployee,
'Employee Onboarding'
);
Where,
- colEmployee = Collection Name
- ‘Employee Onboarding’ = SharePoint Online List
3. Insert a Data table control and set Its Items property as:
Items = colEmployee
4. To display the collection fields on the data table, click on the Edit fields options and add respective fields as shown below.
5. Insert a Text label and set its Text property to the code below.
Text = "Total Number of Rows in collection: " & CountRows(colEmployee)"
Where,
- CountRows() = This function is used to count the number of rows/records in a table
- colEmployee = Power Apps collection name
6. Once the app is ready, Save, Publish, and Preview the app. The text label shows all collection rows or records count as in the screenshot below.
This is how to count all rows in a Power Apps collection from the SharePoint list.
Conclusion
This Power Apps tutorial taught in detail information about the Count rows in a Power Apps collection, including:
- How to Count All Rows in Power Apps Collection manually
- Count All Rows/ Records in Power Apps Collection from SharePoint List
Also, you may like some more Power Apps tutorials:
- Set Power Apps Gallery Control Row Color
- Set Up Power Apps Gallery Border Between Items
- Get Row Number in Power Apps Gallery
- How to Increment Number in Power Apps Gallery
- Remove Items From Power Apps Collection
- How to Patch Power Apps Collection to SharePoint List?
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