The CountA function in Power Apps is used to count the number of non-blank values in a column of a single-column table or collection. This function is useful for scenarios where you need to determine the number of filled entries in a dataset, especially when dealing with optional fields that might contain blank values.
PowerApps – CountA() function Syntax
CountA(SingleColumnTable)
- SingleColumnTable: The table from which you want to count the non-blank values. This should be a single column table or collection.
Notes:
- This function includes empty text (“”) in the count.
- Handling Blanks: Ensure that your data source or collection correctly represents blank values to avoid incorrect counts.
- Delegation: Be mindful of delegation limits when using CountA with large data sources. Ensure that your formulas are delegable to handle large datasets efficiently.
PowerApps - Count Non-Blank Values in a Collection
Suppose you have a collection named Products with some blank values in the ProductName column, and you want to count the number of non-blank product names.
- Create the Collection:
ClearCollect(Products,
Table(
{ ProductName: "Laptop},
{ ProductName: Blank()},
{ ProductName: "Monitor"}
)
);
- Count Non-Blank Product Names:
- Add a Label control.
- Set the Text property of the Label to:
This will display the number of non-blank product names in the Products collection, which is 2.
PowerApps - Count Non-Blank Values in a Data Source
Suppose you have a SharePoint list named Employees with some blank values in the Email column, and you want to count the number of non-blank email addresses.
- Connect to the SharePoint List:
- In Power Apps, go to the Data tab.
- Add a data source and connect to your SharePoint site and list (Employees).
- Count Non-Blank Email Addresses:
- Add a Label control.
- Set the Text property of the Label to:
This will display the number of non-blank email addresses in the Employees SharePoint list.
PowerApps - Combine CountA with Other Functions
You can combine CountA with other functions to perform more complex operations. For example, count the number of non-blank values in a filtered collection.
- Filter and Count Non-Blank Values:
- Add a Label control.
- Set the Text property of the Label to:
CountA(Filter(Products, Price > 400))
This will count the number of non-blank product names for products with a price greater than 400.