Angular Data Grid Aggregates
The aggregates in the Angular Grid help you to easily perform various mathematic operations with the values of grouped columns. Aggregates are commonly displayed inside Group Templates.
The following example demonstrates how to aggregate the data by the Amount field.
To apply aggregates by specific fields:
- 
Create an array of
AggregateDescriptorobjects that define aggregates for the required fields.tspublic myAggregates: AggregateDescriptor[] = [ { field: 'Amount', aggregate: 'sum' } ]; - 
Set the created aggregates array to the
aggregatesproperty of theGroupDescriptorfor the respective field.tspublic group: GroupDescriptor[] = [ { field: 'transactionType', aggregates: this.myAggregates } ];By design, the aggregates are not persisted, and you must apply them manually. Make sure to update the
aggregatesproperty of theGroupDescriptorin thegroupChangeordataStateChangeevent handler.tsonGroupChange(group) { // set the desired aggregates to the incoming GroupDescriptor group.map((group) => (group.aggregates = this.aggregates)); this.group = group; this.gridData = groupBy(sampleProducts, this.group); } - 
Use the
aggregatesfield passed by each template to access and display the created aggregates from step 1.html<kendo-grid [group]="group"...> <kendo-grid-column field="amount"> <ng-template kendoGridGroupFooterTemplate let-aggregates="aggregates"> <span> Sum: {{aggregates.amount.sum}} </span> </ng-template> </kendo-grid-column> </kendo-grid> 
Aggregate Types
The Grid supports the following aggregate functions for mathematical calculations on grouped data:
sum—Calculates the total of all numeric values in the groupaverage—Calculates the average of all numeric values in the groupcount—Returns the number of items in the groupmin—Finds the smallest value in the groupmax—Finds the largest value in the group
The following example demonstrates how to calculate several aggregates and display them in the footer template.