Cumulative Calculated Columns
Summary
- Cumulative Calculated Columns perform cumulative aggregations
- The aggregation operation is applied to each row cumulatively in a specific, given order
Calculated Columns are able to display Cumulative Expressions.
These are an advanced form of Aggregation Expression.
They are similar in that the values derive from multiple rows but with one fundamental difference: they perform that perform cumulative aggregations.
This means that the aggregation operation (e.g., SUM, MIN, MAX) is applied to each row cumulatively in a specific, given order.
Hint
This is particularly useful, for example, when we want to calculate a Running Total of a column
Developer Guide
Defining a Cumulative Calculated Column
There are 5 properties that you need to provide when defining a Cumulative Calculated Column:
CalculatedColumn: {
CalculatedColumns: [
{
ColumnId: 'cumulated-stars-count',
FriendlyName: 'Cumulated Stars Count',
Query: {
AggregatedScalarExpression:
'CUMUL( SUM([github_stars]), OVER([created_at]) )',
},
CalculatedColumnSettings: {
DataType: 'number',
Filterable: true,
},
},
{
ColumnId: 'max-tech-debt-over-stars',
FriendlyName: 'Maximum Technical Debt',
Query: {
AggregatedScalarExpression:
'CUMUL( MAX([open_issues_count]), OVER([github_stars]) )',
},
CalculatedColumnSettings: {
DataType: 'number',
Sortable: true,
},
},
],
},This ColumnId value is used to reference the Column in AdapTable State and in other objects (e.g. Layouts).
This value is used to refer to the Column in AdapTable UI.
It only needs to be provided if the ColumnId value is unsuitable.
This is a Cumulative Expression evaluated by AdapTableQL cumulatively across the grid in a specified order.
It is wrapped inside a Query property under the AggregatedScalarExpression key and uses the CUMUL function with an inner aggregation (SUM, MIN, MAX, etc.) and an OVER clause that sets the ordering.
The Data Type of the Calculated Column should be provided in CalculatedColumnSettings.
It is a Cell Data Type value and the object's only mandatory property. Common values are number, text or date.
Additional Settings for the Calculated Column (other than mandatory DataType) can be provided, including:
FilterablePivotableSortableGroupable
- This demo contains 2 Calculated Columns that use Cumulative Aggregation Scalar Expressions:
Cumulated Stars Count- displays the cumulative sum of stars count of all repos in the grid, aggregated over theCreateddateMaximum Technical Debt- shows the cumulative maxima of open issues of all repos in the grid, aggregated over theGitHub Starscount
- The Calculated Columns are formatted using Column Formatting.