Skip to content

CountDistinct

Aggregation

CountDistinct(column)

Counts distinct non-NULL values (SQL COUNT(DISTINCT col)). Over zero rows it returns 0.

  • 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.
Orders := CountDistinct(Sales.OrderId)
  • Not additive — it cannot be accumulated by YTD/RollingSum (SQX015): a sum of daily distinct counts double-counts repeat values.