--- title: "Aggregation | Features" description: "ZingGrid can calculate the avg, count, min, max, and sum values for a column or row. These aggregation values are displayed in a row or column, respectively, in the grid." url: https://www.zinggrid.com/docs/features/aggregation --- ```text experiment_id: web-retrieval-v1 fixture_id: /docs/features/aggregation.md mode: provenance representation: markdown origin_response_id: 9692b78649b5f0cf218f128610dde2d4 version: 2026-10-21 version_created_at_utc: 2026-10-21T20:42:35.672Z version_nonce: 56f7a32bbc3c17dbc07b3afd124b330c generated_at_utc: 2026-11-08T09:56:38.486Z response_nonce: 908ee3fd274ed715ecb950bd8e4ed902 ``` # Aggregation ZingGrid has default behaviors for calculating the average, count, min, max, and sum values for a given column or row. These aggregation values are displayed in a row or column, respectively, in the grid. ## Aggregate Column Display the average of a column by setting the column `type` to "aggregate" and specifying `type-aggregate-value` to "avg" (average): ```html ``` For a list of aggregate methods available for `type-aggregate-value`, check out the [Aggregate Methods](https://www.zinggrid.com/docs/features/aggregation#aggregate-methods) section. [Example code](https://app.zingsoft.com/demos/embed/6LP4M0FD) ## Specify or Omit Columns By default, all number-like column types (currency, date, number, etc...) are included in calculating the value of an aggregate column. To specify which columns to include in the calculations, set the `index` attribute to a list of column indices. ```html ``` Alternatively, add `type-aggregate-omit` to the column(s) to omit from the aggregate calculation. ```html ``` [Example code](https://app.zingsoft.com/demos/embed/TYRSA80K) ## Custom Renderer To customize the aggregate column, specify `renderer` to the name of your custom renderer function. The function definition of the renderer should be `function(recordData, aggregateData, aggreateValue)`. ```html ``` [Example code](https://app.zingsoft.com/demos/embed/B3KDL51U) ## Aggregate Row Aggregate can also be displayed as a row. Display the average of a column's values in the footer with `foot-cell`: ```html ``` Or display the average in the header with `head-cell`: ```html ``` For a list of aggregate methods available for `foot-cell` and `head-cell`, check out the [Aggregate Methods](https://www.zinggrid.com/docs/features/aggregation#aggregate-methods) section. [Example code](https://app.zingsoft.com/demos/embed/GRBI5HDD) ## Aggregate Grand Total To display the grand total, enable both aggregate columns and rows. The grand total is displayed in the head and/or foot cells of the aggregate columns. ```html ``` [Example code](https://app.zingsoft.com/demos/embed/SH9RGJPE) ## Aggregate Totals Field To display the aggregate of all numeric values of the grid, use the aggregate column with `head-cell` or `foot-cell`. Omit `type-aggregate-value`, which returns the aggregate of the columns and rows. ```html ``` [Example code](https://app.zingsoft.com/demos/embed/76ZDIX53) ## Aggregate Methods Here are a list of aggregate methods available to set for `type-aggregate-value` (column), `head-cell` or `foot-cell`. ### Average Display the average value of a column in the footer, like so: ```html ``` Here is a complete grid with the average of each column calculated in the grid's footer: [Example code](https://app.zingsoft.com/demos/embed/7H2MN3A5) ### Count Display the count value of a column in the footer, like so: ```html ``` Here is a complete grid with the number of rows containing data calculated for each column in the grid's footer: [Example code](https://app.zingsoft.com/demos/embed/EBVT8LGK) ### Min Display the minimum value of a column in the footer, like so: ```html ``` Here is a complete grid displaying the lowest value of each column in the grid's footer: [Example code](https://app.zingsoft.com/demos/embed/HG9ZJYP4) ### Max Display the maximum value of a column in the footer, like so: ```html ``` Here is a complete grid displaying the highest value of each column in the grid's footer: [Example code](https://app.zingsoft.com/demos/embed/SKG1ARGZ) ### Sum Display the sum total of a column's values in the footer, like so: ```html ``` Here is a complete grid with the sum total of each column calculated in the grid's footer: [Example code](https://app.zingsoft.com/demos/embed/W07GKZO1) ### Tokenized String Display custom text with the aggregate value using a tokenized string. The tokens represent the aggregate value. Specify an aggregate value by placing the aggregate method between double brackets, like so: ```html ``` Here is a complete grid with a tokensized string with the average of each column calculated in the grid's footer: [Example code](https://app.zingsoft.com/demos/embed/2VVEGMTN) ### Custom Method Display an aggregate value based on your own custom aggregate method. Specify the aggregate method by the function name, like so: ```html ``` Here is a complete grid with a custom aggregate caclulation of each column in the grid's footer: [Example code](https://app.zingsoft.com/demos/embed/MQZ474KU) [Example code](https://app.zingsoft.com/demos/embed/OHE5IKGY) ## Related Resources Here are some extra resources related to this feature to help with creating your grid: * [Column Features](https://www.zinggrid.com/docs/api/tags/zg-column)