Aggregation functions

An aggregation function defines how several data entries are combined into one summary value.

This guide explains the available aggregation functions and how to set them.

Available aggregations

NameValueDescription
Sum"sum"Calculates a sum of the field values. Can be applied to fields of the integer and float types.
Average"average"Calculates the average of the field values. Can be applied to fields of the integer and float types.
Count"count"Counts the number of records. Can be applied to fields of all types.
Distinct Count"distinct_count"Counts the number of unique values. Can be applied to fields of integer, float, string, date, datetime, and time types.
Median"median"Calculates the median of the field values. Can be applied to fields of the integer and float types.
Product"product"Calculates the product of the field values. Can be applied to fields of the integer and float types.
Min"min"Returns the smallest field value. Can be applied to fields of integer, float, date, datetime, and time types.
Max"max"Returns the largest field value. Can be applied to fields of integer, float, date, datetime, and time types.
First"first"Returns the first field value in the records. Can be applied to fields of the string type.
Last"last"Returns the last field value in the records. Can be applied to fields of the string type.
Or"or"Returns true if at least one field value is truthy. Can be applied to fields of the boolean type.
And"and"Returns true only if all field values are truthy. Can be applied to fields of the boolean type.
True Count"true_count"Calculates the number of truthy field values. Can be applied to fields of the boolean type.
False Count"false_count"Calculates the number of falsy field values. Can be applied to fields of the boolean type.

Default aggregations

When adding a field to the grid without setting any aggregation function, the aggregation will be chosen automatically based on the field's data type:

  • Sum is the default function for integer and float data types.
  • Count is the default function for the string data type.
  • Min is the default function for date, datetime, and time data types.
  • Or is the default function for the boolean data type.

How to change the aggregation for a field

You can set aggregation functions either via the field list in the UI or through the code. This section explains how to apply them in both pivot and flat tables.

In the pivot table

In the flat table

Note By default, totals are hidden in the flat view, and aggregations cannot be applied. Learn how to show totals on the grid.

See also