COUNTX

The COUNTX function counts the number of rows in a table for which the evaluation of an expression returns a number, a date, or a text.

Syntax

COUNTX(
    table,
    expression
)

Parameters
  • table: Table containing the rows for which the expression will be evaluated.
  • expression: Expression to evaluate for each row of the table.
Returned value

The COUNTX function returns an integer.

Additional Information

The function evaluates the expression included as the second argument for each of the rows of the indicated table, returning the number of those rows that return numbers, dates or texts. If no rows are found, a Blank is returned. If rows are found but none satisfy the specified condition, a zero is returned.

To count logical values, the COUNTA or COUNTAX functions must be used.

The table argument can be either a table or a function that returns a table.

Examples

In this example we have a list of products that includes the price and the number of stocks of each one. If a product does not have a price assigned or the number of stocks is unknown, the table includes an empty cell:

COUNTX function. Example of use

We can count the number of products for which there is both an assigned price and a known stock with the following measure:

Número de productos = COUNTX(Productos, Productos[Precio] * Productos[Existencias])

...measure that, taken to a display of type "card", returns the following result:

COUNTX function. Example of use

Related functions
Category
Statistical
Submitted by admin on Mon, 12/03/2018 - 23:06