DAX DISTINCTCOUNT function
Counts the number of different values in a column.
DISTINCTCOUNT answers "how many different…?": customers, products, countries. Each value is counted once, however many rows it appears in.
Syntax
DISTINCTCOUNT(<column>)| Argument | Required | Description |
|---|---|---|
| column | Required | The column whose different values are counted. |
Returns: A whole number.
Examples
Calculated on the free practice data (table financials), with [Total Sales] = SUM(financials[Sales]) and [Total Profit] = SUM(financials[Profit]).
1. Products sold in each country
Products Sold = DISTINCTCOUNT(financials[Product])| Country | Products Sold |
|---|---|
| Canada | 6 |
| France | 6 |
| Germany | 6 |
| Mexico | 6 |
| United States of America | 6 |
| Total | 6 |
Every country sells all six products, so every row shows 6.
2. Countries per segment
Countries = DISTINCTCOUNT(financials[Country])| Segment | Countries |
|---|---|
| Channel Partners | 5 |
| Enterprise | 5 |
| Government | 5 |
| Midmarket | 5 |
| Small Business | 5 |
| Total | 5 |
How many different countries each segment sells in.
Good to know
- A blank value counts as one value. DISTINCTCOUNTNOBLANK skips it.
- Distinct counts don't add up: the total row counts distinct values over everything, not the sum of the rows.
Related functions
Official reference: DISTINCTCOUNT function on Microsoft Learn