CountDistinct

CountDistinct function will eliminate any duplicate values from the count and will return the number of records with unique and non-null values.

Syntax :

CountDistinct(Expression,[Condition])
Parameters Description
Expression Total count of all the distinct values.
[Condition] [OPTIONAL] - Calculation to determine if row should be included or not

Example :

Table Name : Products

ProductID Product Name Price
1 Pen 6
2 Pencil 3
3 Eraser 2
4 Bottle 5
5 Book 10
6 Pencil 3

Example 1

dCountDistinct = CountDistinct(Price)
DEBUG(dCountDistinct)

Result :

dCountDistinct
= 5

Example 2

dCountDistinct = CountDistinct(Price,ProductID<>1)
DEBUG(dCountDistinct)

Result :

dCountDistinct
= 4