CountDistinct
Aggregation
CountDistinct(column)
Counts distinct non-NULL values (SQL COUNT(DISTINCT col)). Over zero rows it returns 0.
When to use it
Section titled “When to use it”- How many unique X — active customers, distinct SKUs sold, days with at least one order.
- Counting entities across a one-to-many join without inflation: an order with five lines counts once.
Example
Section titled “Example”Orders := CountDistinct(Sales.OrderId)Good to know
Section titled “Good to know”- Not additive — it cannot be accumulated by
YTD/RollingSum(SQX015): a sum of daily distinct counts double-counts repeat values.