✅ You are viewing documentation for the latest version of Compose SDK.
Version:
# Function countDistinct
countDistinct(
attribute,name?,format?):BaseMeasure
Creates a count distinct aggregation measure over the given attribute.
To count all values in the given attribute, use count.
# Parameters
| Parameter | Type | Description |
|---|---|---|
attribute | Attribute | Attribute to aggregate |
name? | string | Optional name for the new measure |
format? | string | Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc. |
# Returns
A measure instance
# Example
Calculate the number of distinct brands from the Sample Ecommerce data model.
measureFactory.countDistinct(DM.Brand.BrandID)