Built-in Functions → count

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

Signature

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

If you use the groupBy function to count the number of items in each group, 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

  • Count the total number of elements in the AMOUNT_SOLD.
count(Sales_Acme.Sales.AMOUNT_SOLD)
  • Count the number of elements in AMOUNT_SOLD as grouped by CITY.
count(Sales_Acme.Sales.AMOUNT_SOLD,byGroup(Sales_Acme.Sales.CITY))