Overview
Calculated columns execute JavaScript formulas to compute values from row data. Common use cases include:- Risk Priority Numbers (RPN) - Multiplying severity × occurrence × detection ratings
- Status indicators - Deriving status from multiple field values
- Metrics and KPIs - Aggregating or transforming data from multiple columns
- Conditional values - Displaying different content based on row conditions
Column Configuration
| Name | Type | Default | Description |
|---|---|---|---|
type | string | required | Data type for the calculated result: "int" (integer), "float" (decimal), "string", "date", "datetime", etc. |
id | string | optional | Unique column identifier. Auto-generated from header or bindings if not specified. |
bindings | string | required | Cell property binding name where the calculated value is stored (e.g., "rpn", "riskScore", "derivedStatus"). |
header | string | required | Column header text displayed in the grid (e.g., “RPN”, “Risk Score”, “Calculated Status”). |
formula | string | required | Reference to a formula definition in the formulas section by ID (e.g., "commonRpn", "customScore"). |
headerGroup | string | optional | Groups multiple columns under a single header section (e.g., “Risk Analysis”, “Metrics”). |
headerGroupCss | string | optional | CSS class for styling the header group section. |
headerCss | string | optional | CSS class for styling the column header cell. |
cellRenderer | string | optional | Custom cell renderer for styled display of formula results (e.g., "rpn" for RPN risk coloring). |
cellCss | string | optional | CSS class applied to all cells in this column for custom styling. |
width | number | optional | Fixed column width in pixels. |
minWidth | number | optional | Minimum column width in pixels when resizing. |
readOnly | boolean | true | Calculated columns are automatically read-only. Cannot be edited directly by users. |
sortable | boolean | true | Whether column values can be sorted. |
filterable | boolean | true | Whether users can filter the Risksheet by calculated values. |
format | string | optional | Display format string (e.g., "0.00" for decimal places, date formats). |
level | number | optional | Hierarchical level where this column appears (1 = top level, 2 = second level, etc.). |
Formula Definition
Formulas are JavaScript functions that receive a parameter object containingitem and cell properties:
| Property | Type | Description |
|---|---|---|
info.item | object | Array of cell values for the current row, accessed by column ID: info.item['columnId'], info.item['sev'], info.item['occ'], etc. |
info.cell | DOM element | HTML cell element (rarely used in formulas, typically used in cellDecorators). |
this context | object | Access to the Risksheet context and utilities. |
Basic Formula Example
Formula Return Values
Formulas must return:- Numeric value - For
int,float,currencycolumn types - String value - For
stringcolumn types - Date object - For
date,datetimecolumn types - Boolean value - For
booleancolumn types - null or undefined - To display empty cell (no value calculated)
Configuration Methods
Method 1: Direct Formula in risksheet.json
Define formulas directly in the configuration file:Method 2: Formulas in Top Panel
For complex or multiple formulas, define function logic in the Risksheet Top Panel: Step 1: Define formula reference in risksheet.json- Multiple formulas sharing logic
- Complex calculations with helper functions
- Formulas needing external library calls
- Keeping risksheet.json configuration clean
Data Type and Formatting
| Column Type | Description | Example Format | Notes |
|---|---|---|---|
int | Integer number | 0 (no decimals) | Formula results are rounded down. Ideal for RPN, counts, scores. |
float | Decimal number | "0.00" | Displays with specified decimal places. Used for percentages, ratios. |
string | Text value | N/A | Returns text from formula. Used for derived status, labels, messages. |
date | Date only | "MM/dd/yyyy" | Formula must return JavaScript Date object. |
datetime | Date and time | "MM/dd/yyyy HH:mm" | Formula must return JavaScript Date object with time component. |
boolean | True/False | N/A | Returns boolean value. Rarely used for display. |
Integer Column Example
Float Column Example
Cell Rendering and Styling
Custom Cell Renderer
Formula results can be styled dynamically using cell renderers:cellRenderer references a cell decorator function that applies CSS classes based on values.
Cell Decorator Example
Define decorators in thecellDecorators configuration section:
rpn1 (low risk), rpn2 (medium risk), rpn3 (high risk) based on RPN thresholds.
Storing Calculated Values
By default, calculated values are not stored in Polarion—they are computed on-the-fly. To persist calculated values:Create Custom Field in Polarion
- In Polarion Administration, create a custom field on the work item type (e.g., “Risk Priority” on Risk type)
- Set field ID to match the
bindingsproperty (e.g.,"rpn") - Mark the field as read-only in Administration to prevent manual editing
- Set
"readOnly": falsein the column configuration to allow programmatic storage
readOnly: false, the calculated value is saved to Polarion on each save operation.
Complex Formula Examples
Conditional Status Calculation
Multi-Step Calculation with Fallbacks
Performance Considerations
| Consideration | Impact | Mitigation |
|---|---|---|
| Heavy calculations | Slows grid rendering if executed on many rows | Limit formula complexity, use lazy evaluation |
| Missing dependencies | Formula fails if source column has null value | Use fallback values: info.item['col'] || 0 |
| Data type mismatches | Formula returns incorrect type for column type | Ensure return type matches column type property |
| Circular references | Avoided by design—formulas are read-only | Safe to reference any other column |
Configuration Checklist
- Define formula in
formulassection with unique ID - Set column
formulaproperty to reference formula ID - Set column
typeto match formula return type (int, float, string, etc.) - Set column
bindingsto the property name where value is stored - Configure
readOnly: true(default) unless storing in Polarion - (Optional) Add
cellRendererfor custom styling - (Optional) Add
formatstring for numeric/date formatting - Verify formula references correct column IDs in
info.item[...] - Test formula with various input combinations
- Document formula logic in comments if complex
Calculated columns cannot be edited directly by users. The read-only state is automatically enforced by the system. Users cannot override calculated values in cells.
Sources
Sources
KB ArticlesSource Code
AppConfigHelper.tsAppConfig.tsrisksheet.jsonPolarionAppConfigManager.javaSheetConstants.ts