Daily DAX : Day 352 DISTINCTCOUNT

DAX DISTINCTCOUNT Function

Description

The DISTINCTCOUNT function in Power BI DAX (Data Analysis Expressions) counts the number of unique values in a column. It ignores duplicates and returns the count of distinct values, including blanks (if present).

Syntax

DISTINCTCOUNT(<column>)
  • <column>: The column containing the values to count distinct entries for.

Return Value

An integer representing the count of unique values in the specified column.

Use Case

DISTINCTCOUNT is commonly used in business intelligence scenarios to analyze unique occurrences, such as:

  • Counting unique customers who made purchases.
  • Calculating the number of distinct products sold in a period.
  • Determining unique website visitors in web analytics.

Example

Suppose you have a table named Sales with a column CustomerID. To count unique customers:

UniqueCustomers = DISTINCTCOUNT(Sales[CustomerID])

If the CustomerID column contains [101, 102, 101, 103, 102, blank], the result is 4 (unique values: 101, 102, 103, and blank).

Notes

  • Blanks are counted as a distinct value.
  • Use with filters (e.g., CALCULATE) to count distinct values within specific conditions.
  • Performance may be impacted with very large datasets; consider optimizing data models.

Comments

Popular posts from this blog

Daily DAX : Day 65 INFO.TABLEPERMISSIONS

Daily DAX : Day 55 PV