About Count, CountX, CountA, CountAX, and difference using DAX in Power BI

Arunagiriharika
4 min readSep 17, 2021

--

If we want to count the number of values in a column.

Let us see the difference in Count, CountX, CountA, CountAx

Example:

Taking a simple example in tabular format

Count:

Count function counts the number of cells in a column that contains numbers, Dates, strings.

The Count function does not count empty (or) blank values.

The Count function does not count boolean functions but
If you include true/false with categorical data and numerical values it will count. The only boolean values does not count.

The Count function contains blank data it returns blank.

In the above picture, you can see I include true/false in the name it will count. In phone numbers blank it returns blank. In fees I had given true it is counted

In the above picture, you can see if you take boolean values it shows an error. The function count cannot work boolean values.

Syntax: COUNT(<column>)

Example : count_id = COUNT(data[id])

I had taken function to count id column.you can see it is 7 so the output is 7.

Output: 7.

CountX:

CountX function counts the number of cells in a column that contains numbers, Dates, strings.

The CountX function does not count empty (or) blank values.

The CountX function does not count boolean values but
If you include true/false with categorical data and numerical values it will count. The only boolean values does not count.

Syntax : CountX (<table_name>,<expression>)

Example : countx_name = COUNTX(data,data[name]).

I had taken the name as count so we can see 7 columns output is 7

Output: 7

The CountX function we can also do filters.

In the above picture, you can see filtered on Power BI you can see count of Power BI.

Syntax : CountX(Filter(table_name,expression)

Example : COUNTX( FILTER(data,data[course]=”power bi”),data[Course])

I want filter how many Power BI numbers are there you can see it is 2 so output is 2

Output : 2.

CountA:

The CountA function counts the number of cells in a column.

The CountA function does not count empty (or) blank values.

The Counta function counts boolean functions.

The CountA function counts numbers, strings, dates, boolean.
The CountA function contains blank data it returns a blank.

In the above picture, you can see boolean values are counted.

Syntax : COUNTA(<column>).

Example : counta_phone number = COUNTA(data[Phone Number])

Output :Blank.(Phone number is blank it returns blank).

CountAX :

The CountAX function counts the number of cells in a column.

The CountAX function does not count empty (or) blank values.

The CountAX function counts boolean values.

the CountAX function counts numbers, strings,dates,boolean values.
the CountAX function contain blank data it return blank.

Syntax : COUNTAX(<table_name>,<expression>)

Example : Countax_logical = COUNTAX(data,data[Logical])

Output:7.

In logical values, you can 7 logical values so the output is 7

In CountAX you can do filters.

In the above picture, you can be filtered how many 10000 are there you can see a count of 10000.

Syntax : CountaX(Filter(table_name,expression)

Example: countax_filter = COUNTAX( FILTER(data,data[fees]=”10000"),data[Fees])

Output : 3

Difference between Count, CountX, CountA, CountAX.

Taking a simple example in tabular format.

--

--