# DAX Language - COUNT and COUNTX

A-Badde | Posted on April 09, 20

COUNT Function

Description:

The COUNT function counts the number of non blank cells in a column.

Return Value:

COUNT returns a whole number, that is the number of non blank cells in the column.

Syntax:

``COUNT( <ColumnName> ) ``
• Description of the parameter:

PARAMETER

DESCRIPTION

ColumnName

Column that contains the values to be counted

Example:

The following example counts the number of values in the column ContinentName.

``Number_Continent = COUNT( Geography[ContinentName] )``

The COUNT function accepts a column as argument only, and that contains numbers, dates or strings values.

COUNTX Function

Description:

The COUNTX function counts the number of rows that contain a non-blank value when evaluating an expression over a table.

Return Value:

COUNTX returns an integer value, result of the count.

Syntax:

``COUNTX( <Table>,<Expression> )``
• Description of the parameters:

PARAMETER

DESCRIPTION

Table

The table containing the rows to be counted

Expression

The expression to be evaluated for each row of the table.

Example:

To calculate the number of rows in the Product table of type "Televisions", and which have a Unit price, we can use the following formula:

``````Measure =
COUNTX(
FILTER('Product',
RELATED(ProductSubcategory[ProductSubcategory])="Televisions"
),
'Product'[UnitPrice]
)``````

This formula passes a filtered table to COUNTX for the first argument. Using FILTER and RELATED functions, we will return all products whose sub category is Televisions, and then counts the rows in the resulting table that have a list price.

The first argument of the COUNTX must always be a table, or any expression that returns a table. The second argument is the column or expression that is searched by COUNTX.

• COUNT and COUNTX return a blank if there are no rows to count.
• TRUE/FALSE values are not supported

Related Video: There is no comment

##### Recent Posts
###### DAX Language - CONTAINS Function

The CONTAINS function returns a boolean value, TRUE if each ...Read More

###### DAX Language - RANKX Function

The RANKX function returns a single integer value that repre...Read More