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 an Expression which can range from straightforward to very complex (we use the Math.JS library)
Once created, a Calculated Column becomes a 'normal' column in your grid and will update automatically as other values change.
In this example we have created 5 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)
- Tax - (a string) which returns the VAT (calculated at 20%) on OrderCost and to which we've added a Display Format
Click the 2nd button in Dasbhoard to see details of the Expression - or 'Edit Expression' in the Column Header menu.
They are treated as 'normal' columns so we included them in the layouts we created (and we grouped on 'Comment') and we also styled them (e.g. 'Profit') using Conditional Styles.