DISTINCTCOUNTNOBLANK DAX Function (Aggregation)

Counts the number of distinct values in a column.

Syntax

DISTINCTCOUNTNOBLANK ( <ColumnName> )
Parameter Attributes Description
ColumnName

The column for which the distinct values are counted, no blank value included.

Return values

Scalar A single integer value.

The number of distinct values in ColumnName, ignoring the blank value.

Remarks

DISTINCTCOUNTNOBLANK is syntax sugar for evaluating DISTINCTCOUNT removing BLANK from the filter context.

The syntax:

DISTINCTCOUNTNOBLANK ( table[column] )

corresponds to:

CALCULATE ( 
    DISTINCTCOUNT ( table[column] ),
    KEEPFILTERS ( NOT ISBLANK ( table[column] ) )
)
» 1 related article
» 2 related functions

Examples

--
--  DISTINCTCOUNT considers BLANK as a valid value, whereas
--  DISTINCTCOUNTNOBLANK does not count any blank value
-- 
DEFINE
    MEASURE Customer[# Stores] =
        COUNTROWS ( Store )
    MEASURE Customer[# Manager] =
        DISTINCTCOUNT ( Store[Area Manager] )
    MEASURE Customer[# Manager (no blank)] =
        DISTINCTCOUNTNOBLANK ( Store[Area Manager] )
    MEASURE Customer[# Stores without manager] =
        COUNTBLANK ( Store[Area Manager] )
EVALUATE
SUMMARIZECOLUMNS ( 
    Store[Continent],
    "# Stores", [# Stores],
    "# Manager", [# Manager],
    "# Manager (no blank)", [# Manager (no blank)],
    "# Stores without manager", [# Stores without manager]
)
ORDER BY
    Store[Continent]
Continent # Stores # Manager # Manager (no blank) # Stores without manager
Asia 41 5 5 (Blank)
Europe 54 8 7 7
North America 209 40 39 5

More examples available for the DISTINCTCOUNT function.

Related articles

Learn more about DISTINCTCOUNTNOBLANK in the following articles:

Related functions

Other related functions are:

Last update: Oct 3, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Mads Hannibal, Kenneth Barber,

Microsoft documentation: https://docs.microsoft.com/en-us/dax/distinctcountnoblank-function-dax

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.

Iterator

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.

Deprecated

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

Volatile

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

Deprecated

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.

Contribute

Want to improve the content of DISTINCTCOUNTNOBLANK? 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.