Quantile Calculated Columns

View as Markdown

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 Column is evaluated by placing each cell's value into a different bucket based on its value relative to others in the group.

Quantile aggregations use the QUANT Expression Function.

This receives a value to evaluate (typically a column name) and the number of buckets to create.

Find Out More

With the Server-Side Row Model, evaluate Quantile Calculated Columns on the server — see Server-Side Row Model - Calculated Columns.

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',
      Expression: 'QUANT{[value], 4}',
      CalculatedColumnSettings: {
        DataType: 'number',
        Filterable: true,
      },
    },
    {
      ColumnId: 'quartile-by-type',
      FriendlyName: 'Quartile by Type',
      Expression: 'QUANT{[value], 4, GROUP_BY([type])}',
      CalculatedColumnSettings: {
        DataType: 'number',
        Sortable: true,
      },
    },
  ],
},
1
Id for the Calculated Column

This ColumnId value is used to reference the Column in AdapTable State and in other objects (e.g. Layouts).

2
Column Friendly Name (if required)

This value is used to refer to the Column in AdapTable UI. It only needs to be provided if the ColumnId value is unsuitable.

3
The Quantile Expression

This is a Quantile Expression evaluated by AdapTableQL by placing each row's value into a bucket relative to other rows.

It is the Expression string of the Calculated Column and uses the QUANT function — a column reference, a number of buckets, and optionally a GROUP_BY clause.

4
Data Type

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.

5
Calculated Column Settings (Optional)

Additional Settings for the Calculated Column (other than mandatory DataType) can be provided, including:

  • Filterable
  • Pivotable
  • Sortable
  • Groupable
adaptable-devAI Skill

Add 2 Quantile Calculated Columns to the current Layout: (a) "Notional Quartile" which will place each row in quartile 1 to 4 based on the Notional column across the whole grid (b) "Desk Size Quintile" which will place each row in quintile 1 to 5 based on the Size column, only comparing rows that share the same Desk

Quantile Calculated Columns
Fork
  • This Example demonstrates how to use the QUANT Expression Function to calculate Quantile functions
  • It contains 100 Tickers each with a Value and a Type
  • 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 groups
    • Quintile - divides the 100 Ticker Values into 5 groups
    • Decile - divides the 100 Ticker Values into 10 groups
    • Percentile - 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_BY keyword:
    • Grouped by Type - creates 3 bucket for each set of Values in each group of a distinct 'Type' (with a Column Display Format)
Try It Out
  • Sort the Grid by Type to see how the Grouped by Type column creates 3 buckets for each dinstinct Type
  • Change some Values and note how this changes all the Quantiles it is placed in
Loading demo…

Find Out More