Count, CountA, CountIf, and CountRows functions in Power Apps

Counts all records in a table, or counts all records that satisfy a condition.

Description

The Count function counts the number of records that contain a number in a single-column table.

The CountA function counts the number of records that aren't blank in a single-column table. This function includes empty text ("") in the count.

The CountIf function counts the number of records in a table that are true for a logical formula. The formula can reference columns of the table.

The CountRows function counts the number of records in a table.

Each of these functions returns a number.

You need to enable the Enhanced delegation for Common Data Service option in the advance settings to make CountIf and CountRows functions delegation to work. To enable the option:

  1. Open the app where you want to use the functions.

  2. Select File > Settings > Advanced settings.

  3. Turn on the Enhanced delegation for Common Data Service option.

    Enable delegation

Important

  • There is a 50K delegation limit if you use CountRows and CountIf functions with filters. There is no hard limit on the CountRows function when extracted directly from the data source because of the cached count that Dataverse keeps.
  • If the CountRows(<Data Source>) function is used without filtering, the count might not be 100% accurate, because the cached count updates periodically. If you need precise count and expect the result to be under the aggregate limit, you can bypass the cached count via CountIf(<Data Source>, True).

Syntax

Count( SingleColumnTable )
CountA( SingleColumnTable )

  • SingleColumnTable - Required. Column of records to count.

CountIf( Table, LogicalFormula )

  • Table - Required. Table of records to count.
  • LogicalFormula - Required. Formula to evaluate for each record of the table. Records that return true for this formula are counted. The formula can reference columns of the table.

CountRows( Table )

  • Table - Required. Table of records to count.

Example

  1. Import or create a collection named Inventory, as the first subprocedure in Show images and text in a gallery describes.

  2. Add a label, and set its Text property to this formula:

    CountIf(Inventory, UnitsInStock < 30)

    The label shows 2 because two products (Ganymede and Callisto) have fewer than 30 units in stock.

  3. Add another label, and set its Text property to this formula:

    CountA(Inventory.UnitsInStock)

    The label shows 5, the number of non-empty cells in the UnitsInStock column.

  4. Add another label, and set its Text property to this formula:

    CountRows(Inventory)

    The label shows 5 because the collection contains five rows.

Note

Can you tell us about your documentation language preferences? Take a short survey.

The survey will take about seven minutes. No personal data is collected (privacy statement).