Returns the count of distinct values for a field or an array.
DistinctCount( fld ) DistinctCount( fld, condFld ) DistinctCount( fld, condFld, cond ) DistinctCount( array )
fld | The name of a field whose values should be counted. |
---|---|
condFld | The name of the field that groups the values of fld (if fld isn't an array). |
cond | A string declaring the type of grouping to be used on condFld. This only makes sense for groups based on Date, DateTime, Time, and Boolean fields. See Summary Field Conditions for a list of strings you can use here. |
array | The name of an array variable whose elements should be counted. |
Numeric value of the amount of distinct values in the field or array.
//counts the distinct values of the array DistinctCount([1,4,2,4,3,2,1,7]) //returns 5
//counts the distinct values of the database field Users.Name DistinctCount({Users.Name})
//counts the distinct value of the prompt field DistinctCount({?p}) //returns 4 if p is a multi value prompt with values (0,1,2,2,4)
//counts the distinct products grouped by vendors DistinctCount({Products.ProductName}, {Vendors.VendorId})
//a formula whose result depends on count of all distinct sales of vendors (Crystal Syntax) DistinctCount({Products.ProductName}, {Vendors.VendorId}) > {?p}
Engine.addGroup
.
if isnull(fld) then ruledout else fld
replace fld with the field you want to create a count on and replace ruledout with a value which will not appear in the data, e.g. -1 or -100 000 000 000