There are several count functions in Power Apps, and all of them draw inspiration from Excel. I will detail them all in this reference but, if you’re familiar with them in Excel, you will be comfortable with them in Power Apps. In the case of the “Count Function,” it returns the number of rows in a single-column table.
Usage
It follows a simple pattern.
- Table (single-column)
Example:
Count([1,2,3])
will return
3
You can also use the Table function to generate a table and then return the number of elements. In this case, you should generate it first into a variable and then use the function; otherwise, the table will disappear as soon as the function runs.
Set('TableVariable', Table({Number:1}, {Number:2}, {Number:3}))
and then you can do
Count(TableVariable)
Limitations
You can only use the function in a single-column table. There isn’t a defined limit to this function, but since it’s created and managed in the device, but you should be careful to count huge datasets to avoid your users’ waiting times or slow applications.
Recommendations:
- Don’t nest it. There’s no real reason to do it, but if you find yourself in a situation where you have nested Count functions in a formula, you should review it because something’s not right.
- Use the smallest number of elements possible in a table. The function is quite fast to run, but with huge tables it may take some time.
- You can count the elements of a function or a formula. If you do so, keep them to a minimum so that you can debug easily the app in case of issues or undesired values.
Sources:
Count, CountA, CountIf, and CountRows functions in Power Apps
Back to the Power Apps Function Reference
Photo by Steve Johnson on Unsplash