Aggregation Function - only

Summary

  • The 'only' aggregation is provided by AdapTable to supplement the Aggregation Functions provided by AG Grid
  • It returns a value if that value is the only one that appears in the aggregated data group

AdapTable provides an only aggregation function for use in Grouped Layouts.

Note

This is separate from, and in addition to, the ONLY aggregation function in AdapTableQL, used in Calculated Columns

The only aggregation returns a value if that value is the only one that appears in the aggregated data group.

Hint

A set of [5, 5, 4] will return null, as will a set of [5, 5, null] - but a set of [5, 5, 5] will return 5

Aggregations: 'Only' Custom Aggregation
Fork
  • In this example we group on the Language Column and provide 2 only aggregations - on the License and Issue Change Columns
  • We have also amended the usual row Data so that all the values for HTML in the License column are "MIT License", and all the TypeScript values in the Issues Change Column are "12"
  • As a result we see the only aggregation return these values for these 2 groups

Hiding Only Aggregation

It is possible to hide the only aggregation if this is not required or useful to your users.

This is done the same way as hiding AG Grid's aggFuncs - via the allowedAggFuncs in each ColumnDef.

Hint

Hide the only aggFunc by omitting it from list of Column's aggFuncs, e.g. allowedAggFuncs: ['sum', 'min', 'max'],

Aggregations: 'Only' Custom Aggregation (Hiding)
Fork
  • In this example we have removed the only aggFunc from the list of available aggFuncs for the Github Stars and Github Watchers columns
  • We have explicitly provided it for the Week Issue Change column (together with sum)
  • We have not provided any allowedAggFuncs for the License column (meaning that only is automatically available together with all AG Grid aggFuncs)