COUNTAX DAX Function (Aggregation)

Counts the number of values which result from evaluating an expression for each row of a table.


COUNTAX ( <Table>, <Expression> )
Parameter Attributes Description

The table containing the rows for which the expression will be evaluated.

Row Context

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

Return values

Scalar A single integer value.

Returns the number of values that are non blank by iterating the provided table.


When the function finds no rows producing a non-blank value, it returns a blank.

COUNTX and COUNTAX are identical in DAX for all the data types except Boolean. COUNTAX can operate on a Boolean data type, whereas COUNTX cannot do that.

» 1 related function


--  COUNT is the short version of COUNTX, when used with one column only
--  In DAX, there are no differences between COUNTA and COUNT
--  COUNTX can be expressed in a more explicit way by using CALCULATE
    MEASURE Customer[# Customers]     = COUNTROWS ( Customer )
    MEASURE Customer[# Individuals 1] = COUNT ( Customer[Customer Name] )
    MEASURE Customer[# Individuals 2] = COUNTX ( Customer, Customer[Customer Name] )
    MEASURE Customer[# Individuals 3] =
        CALCULATE ( 
            COUNTROWS ( Customer ), 
            NOT ISBLANK ( Customer[Customer Name] ) 
    "# Customers",     [# Customers],
    "# Individuals 1", [# Individuals 1],
    "# Individuals 2", [# Individuals 2],
    "# Individuals 3", [# Individuals 3]
Continent # Customers # Individuals 1 # Individuals 2 # Individuals 3
Asia 3,658 3,624 3,624 3,624
North America 9,665 9,527 9,527 9,527
Europe 5,546 5,525 5,525 5,525
--  COUNTX is needed when you need to count the result of a formula
--  In this case, COUNTX reads better than CALCULATE
    MEASURE Customer[# Individuals Children/Car 1] =
        COUNTX ( Customer, DIVIDE ( Customer[Total Children], Customer[Cars Owned] ) )
    MEASURE Customer[# Individuals Children/Car 2] =
        COUNTROWS (
            FILTER (
                NOT ISBLANK ( DIVIDE ( Customer[Total Children], Customer[Cars Owned] ) )
    "# Individuals Children/Car 1", [# Individuals Children/Car 1],
    "# Individuals Children/Car 2", [# Individuals Children/Car 2]
Continent # Individuals Children/Car 1 # Individuals Children/Car 2
Asia 3,203 3,203
North America 7,507 7,507
Europe 3,536 3,536

Related functions

Other related functions are:

Last update: Jul 12, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

Microsoft documentation:

2018-2024 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.


Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.


This function is deprecated. Jump to the Alternatives section to see the function to use.


A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.


This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.


Want to improve the content of COUNTAX? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.