{{sidenavigation.sidenavigationExpandLabel}}
{{getMsg('Help_YouAreHere')}}: {{page.title}} {{page.title}}
{{$root.getMsg("downLoadHelpAsPdf")}} {{helpModel.downloadHelpPdfDataStatus}}

DistinctCount

Returns the count of distinct values for a field or an array.

Usage:

DistinctCount( fld )
DistinctCount( fld, condFld )
DistinctCount( fld, condFld, cond )
DistinctCount( array )

Parameters:

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.

Returns:

Numeric value of the amount of distinct values in the field or array.

Examples:

//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}

Notes:

  • If the values in fld should be grouped, a group based on condFld is needed. If the group does not exist in the report, you can add it using i-net Designer or using API method: Engine.addGroup.
  • NULL values will not be counted. The function returns 0, if fld contains only NULL values.
    As workaround you could compute the count of the following formula:
      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

i-net Clear Reports
This application uses cookies to allow login. By continuing to use this application, you agree to the use of cookies.


Help - DistinctCount