Calculated Column Demo

Calculated columns are custom columns that you create (at design or run time) where the value is not in the underlying dataset but is dynamically derived from other cells in the row.

You create Calculated Columns via the Expression Editor where you can drag and drop the Columns and functions you need, or write the expression by hand.

A Calculated Column contains a Scalar Expression, meaning that it can return any single value, and it will update automatically as other values change.

In this example we have created 6 Calculated Columns:

  • Avg Item Cost - (numeric) which divides ItemCost by ItemCount
  • Profit - (numeric) which calculates Invoiced Cost minus sum of Order Cost and Package Cost
  • Comment - (a string) which returns 'Low' if ItemCost is less than 50, 'Medium' if greater than 50 and 'High' if greater than 100.
  • Highest Cost - (a number) which returns the largest of ItemCost, OrderCost, InvoicedCost and PackageCost (the latter being first multiplied by 10)
  • ShipDelay - (a boolean) which returns true if ShippedDate is 35 days later than theOrderDate
  • Tax - (a number) which returns the VAT (calculated at 20%) on Profit (if it is positive)

Click the 1st button in Dashboard to see details of the Expression - or 'Edit Expression' in the Column Header menu.

Calculated Columns are treated as 'normal' columns and can be referenced in other AdapTable objects; in this demo these Calculated Columns are referenced elsewhere:

  • Comment in the grouped calc cols layout
  • Profit in 2 Conditional Styles which use Predicates (Positive and Negative)
  • High Cost in a Row-based Conditional Style that uses an Expression
  • Ship Delay has been styled as a CheckboxColumn in the Format Column Module
  • Profit has been given a Display Format with a Prefix (of '$') and a Suffix (of '20% VAT)

Calculated Columns can also be used in the Expression for other Calculated Columns - as in this Demo where the Tax Calculated Column references Profit.

Generating dummy data, please wait ...