#### DistinctCount

##### DistinctCount(Number a[ ])

This function computes the number of distinct values in an array.

Parameter

a - A Number array.

Return value

The return value is an Integer.

Example

The return value of the following statement is 4.

`DistinctCount([1.45, 2.63, 38.1, 1.45, 23.9])`

##### DistinctCount(DBField a)

This function computes the number of distinct values referred to by a DBField.

Parameter

a - Values of a DBField or a formula field.

Return value

The return value is an Integer.

Example

If you build a report about customer order, the return value of the following statement is 19.

`DistinctCount(@"Order Date")`

##### DistinctCount(DBField a, String groupby)

This function is used to count the number of distinct values referred to by the first argument.

Parameters

- a - Values of a DBField or a formula field.
- groupby - A constant string to indicate the DBField name, formula name or parameter name grouped by.

Return value

Returns a Number type value.

Examples

- `Number x = DistinctCount(@dbfield, @dbfield1)`
- `Number x = DistinctCount(@formula, @formula_groupby)`
- `Number x = DistinctCount(@dbfield, @parameter_groupby)`

Note: If a field is assigned to a variable, for example x, the variable x will lose the characteristic of representing a group of values. The following formula will be treated as incorrect.

`Number x = @dbfield;
Number y = DistinctCount(x); // system will prompt you that there is no such kind of function.`