Built-in Functions → distinct

distinct() is an aggregation function that returns the number of distinct elements in a column.

Signature

distinct(<object> expr, [groupBy(...)])
  • expr : any Incorta column data type
  • groupBy : optional grouping function that specifies which group of data to operate over
Note

If you use the groupBy function, you must include all the leading grouping dimensions in the Insight from the top-down to the level-based measure you want to evaluate. For more information, refer to Aggregation with a Level Based Measure.

Returns

long or as many longs as there are groups if groupBy is used

Examples

  • Determine the number of different (distinct) models sold.
distinct(Sales_Acme.Sales.model_name)
  • Determine the number of different models sold by city.
distinct(Sales_Acme.Sales.model_name, byGroup(Sales_Acme.Sales.city))