DISTINCTCOUNT
How many different values a column holds; a blank, if there is one, is one of them.
Group: Aggregation. Compatible with DAX.
Syntax
DISTINCTCOUNT ( <column> )
| Parameter | Type | Description |
|---|---|---|
column | Column | The column whose different values are counted. |
Returns
Whole number. How many different values the column has in the current filter context.
Remarks
- A blank is counted as one more value when the column has any;
DISTINCTCOUNTNOBLANKleaves it out. - It equals
COUNTROWS ( VALUES ( column ) ), which also counts a blank row. - When no row is left in the filter context, the result is BLANK.
Examples
Shops and products
EVALUATE
ROW (
"Shops", DISTINCTCOUNT ( Sales[Shop] ),
"Products", DISTINCTCOUNT ( Sales[Product] )
)
| Shops | Products |
|---|---|
| 15 | 4 |
The blank is one of the values
Three different prices and a blank: four values. Without the blank: three.
EVALUATE
ROW (
"DISTINCTCOUNT", DISTINCTCOUNT ( Holdings[Price] ),
"DISTINCTCOUNTNOBLANK", DISTINCTCOUNTNOBLANK ( Holdings[Price] )
)
| DISTINCTCOUNT | DISTINCTCOUNTNOBLANK |
|---|---|
| 4 | 3 |
Related functions
DISTINCTCOUNTNOBLANK, APPROXIMATEDISTINCTCOUNT, VALUES, DISTINCT, COUNTROWS.