COUNT_CUMULATIVE
Tom Azernour avatar
Written by Tom Azernour
Updated over a week ago

Type: Function

Function: COUNT_CUMULATIVE

Syntax: COUNT_CUMULATIVE() or COUNT_CUMULATIVE(field)

Description: Returns a cumulative count of records for each grouping, which takes into account the counts of previous groupings. The return values of this aggregator therefore depend on the sort order of the groupings (ascending or descending). When a field is provided the function counts the number of records where the field value is not null.

Important: requires sorting on a dimension

The COUNT_CUMULATIVE operator requires sorting your data on a dimension column. Sorting your data on a metric (e.g. another COUNT column) will result in incorrect results for the cumulative operator.

Sample usage:

  • COUNT_CUMULATIVE() returns the cumulative count of records, based on the requested sort order.

  • COUNT_CUMULATIVE(due_on) returns the cumulative count of records where due_on is not null.

  • ROUND(COUNT_CUMULATIVE() / COUNT_TOTAL(), 2) * 100 returns the percentage that each accumulated count up until this point represents in comparison to the grand total.

Did this answer your question?