Quantile Calculated Columns
Summary
- Quantile Calculated Columns allow 'buckets' of values to be created
- Each cell is placed into a specific bucket based on its value relative to others in the group
Calculated Columns are able to display Quantile Expressions.
These are an advanced form of Aggregation Expressions that perform quantile aggregations.
The Calculated Colunn is evaluated by placing each cell's value into a different bucket based on its value relative to others in the group.
Quantile Aggregation leverage the QUANT Expression Function.
This receives a value to evaluate (typically a column name) and the number of buckets to create.
Developer Guide
Defining a Quantile Calculated Column
There are 5 properties that you need to provide when defining a Quantile Calculated Column:
CalculatedColumn: {
CalculatedColumns: [
{
ColumnId: 'quartile',
FriendlyName: 'Quartile',
Query: {
AggregatedScalarExpression:
'QUANT([value], 4)',
},
CalculatedColumnSettings: {
DataType: 'number',
Filterable: true,
},
},
{
ColumnId: 'quartile-by-type',
FriendlyName: 'Quartile by Type',
Query: {
AggregatedScalarExpression:
'QUANT([value], 4, GROUP_BY([type]))',
},
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 Quantile Expression evaluated by AdapTableQL by placing each row's value into a bucket relative to other rows.
It is wrapped inside a Query property under the AggregatedScalarExpression key and uses the QUANT function — a column reference, a number of buckets, and optionally a GROUP_BY clause.
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 Example demonstrates how to use the
QUANTExpression Function to calculate Quantile functions - It contains 100 Tickers each with a
Valueand aType - The provided Value is from 1 to 100 in ascending order (in order to demonstrate how Quantiles work)
- 4 Calculated Columns are provided in the Initial Adaptable State - each using
QUANT:Quartile- divides the 100 Ticker Values into 4 groupsQuintile- divides the 100 Ticker Values into 5 groupsDecile- divides the 100 Ticker Values into 10 groupsPercentile- divides the 100 Ticker Values into 100 groups (so there is therefore just 1 value per group)
- A 5th Calculated Column illustrates how to group Quantiles by levering the
GROUP_BYkeyword:Grouped by Type- creates 3 bucket for each set of Values in each group of a distinct 'Type' (with a Column Display Format)
- Sort the Grid by Type to see how the
Grouped by Typecolumn creates 3 buckets for each dinstinct Type - Change some Values and note how this changes all the Quantiles it is placed in
Find Out More
See Quantile Aggregation Scalar Expressions for more information