Count, CountA, CountIf, and CountRows functions in PowerApps

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 records in a table.

Each of these functions returns a number.

When used with a data source, these functions can't be delegated. Only the first portion of the data source will be retrieved and then the function applied. The result may not represent the complete story. A blue dot will appear at authoring time to remind you of this limitation and to suggest switching to delegable alternatives where possible. For more information, see the delegation overview.

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.