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>)
ArgumentRequiredDescription
columnRequiredThe 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])
CountryProducts Sold
Canada6
France6
Germany6
Mexico6
United States of America6
Total6

Every country sells all six products, so every row shows 6.

2. Countries per segment

Countries = DISTINCTCOUNT(financials[Country])
SegmentCountries
Channel Partners5
Enterprise5
Government5
Midmarket5
Small Business5
Total5

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