Skip to main content

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

NameTypeDefaultDescription
typestringrequiredData type for the calculated result: "int" (integer), "float" (decimal), "string", "date", "datetime", etc.
idstringoptionalUnique column identifier. Auto-generated from header or bindings if not specified.
bindingsstringrequiredCell property binding name where the calculated value is stored (e.g., "rpn", "riskScore", "derivedStatus").
headerstringrequiredColumn header text displayed in the grid (e.g., “RPN”, “Risk Score”, “Calculated Status”).
formulastringrequiredReference to a formula definition in the formulas section by ID (e.g., "commonRpn", "customScore").
headerGroupstringoptionalGroups multiple columns under a single header section (e.g., “Risk Analysis”, “Metrics”).
headerGroupCssstringoptionalCSS class for styling the header group section.
headerCssstringoptionalCSS class for styling the column header cell.
cellRendererstringoptionalCustom cell renderer for styled display of formula results (e.g., "rpn" for RPN risk coloring).
cellCssstringoptionalCSS class applied to all cells in this column for custom styling.
widthnumberoptionalFixed column width in pixels.
minWidthnumberoptionalMinimum column width in pixels when resizing.
readOnlybooleantrueCalculated columns are automatically read-only. Cannot be edited directly by users.
sortablebooleantrueWhether column values can be sorted.
filterablebooleantrueWhether users can filter the Risksheet by calculated values.
formatstringoptionalDisplay format string (e.g., "0.00" for decimal places, date formats).
levelnumberoptionalHierarchical level where this column appears (1 = top level, 2 = second level, etc.).

Formula Definition

Formulas are JavaScript functions that receive a parameter object containing item and cell properties:
PropertyTypeDescription
info.itemobjectArray of cell values for the current row, accessed by column ID: info.item['columnId'], info.item['sev'], info.item['occ'], etc.
info.cellDOM elementHTML cell element (rarely used in formulas, typically used in cellDecorators).
this contextobjectAccess to the Risksheet context and utilities.

Basic Formula Example

"formulas": {
  "commonRpn": "function(info){ var value = info.item['sev']*info.item['occ']*info.item['det']; return value?value:null; }"
}
This formula multiplies Severity (sev) × Occurrence (occ) × Detection (det) to calculate RPN.

Formula Return Values

Formulas must return:
  • Numeric value - For int, float, currency column types
  • String value - For string column types
  • Date object - For date, datetime column types
  • Boolean value - For boolean column 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:
{
  "formulas": {
    "commonRpn": "function(info){ var sev = info.item['sev']; var occ = info.item['occ']; var det = info.item['det']; var value = sev*occ*det; return value?value:null; }",
    "customScore": "function(info){ var score = (info.item['priority']*2) + info.item['impact']; return Math.round(score); }"
  },
  "columns": [
    {
      "header": "RPN",
      "bindings": "rpn",
      "type": "int",
      "formula": "commonRpn",
      "cellRenderer": "rpn",
      "width": 60
    },
    {
      "header": "Risk Score",
      "bindings": "riskScore",
      "type": "int",
      "formula": "customScore",
      "width": 80
    }
  ]
}
Suitable for simple to moderately complex formulas. Keep the configuration file readable by avoiding very long function bodies.

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
"formulas": {
  "commonRpn": "(info) => { return getCommonRpn(info); }",
  "advancedMetric": "(info) => { return calculateAdvancedMetric(info); }"
}
Step 2: Configure column to use formula
"columns": [
  {
    "header": "RPN",
    "bindings": "rpn",
    "type": "int",
    "formula": "commonRpn",
    "width": 60
  }
]
Step 3: Implement function in Top Panel (HTML/JavaScript) Open Risksheet configuration and add to the Top Panel section:
<script type="text/javascript">
  function getCommonRpn(info) {
    var sev = info.item['sev'] || 0;
    var occ = info.item['occ'] || 0;
    var det = info.item['det'] || 0;
    var value = sev * occ * det;
    return value ? value : null;
  }

  function calculateAdvancedMetric(info) {
    var baseScore = info.item['severity'] || 0;
    var multiplier = info.item['probability'] || 1;
    var weight = info.item['importance'] || 1;
    var result = (baseScore * multiplier) + weight;
    return Math.round(result * 100) / 100;
  }
</script>
This method is recommended for:
  • Multiple formulas sharing logic
  • Complex calculations with helper functions
  • Formulas needing external library calls
  • Keeping risksheet.json configuration clean

Data Type and Formatting

Column TypeDescriptionExample FormatNotes
intInteger number0 (no decimals)Formula results are rounded down. Ideal for RPN, counts, scores.
floatDecimal number"0.00"Displays with specified decimal places. Used for percentages, ratios.
stringText valueN/AReturns text from formula. Used for derived status, labels, messages.
dateDate only"MM/dd/yyyy"Formula must return JavaScript Date object.
datetimeDate and time"MM/dd/yyyy HH:mm"Formula must return JavaScript Date object with time component.
booleanTrue/FalseN/AReturns boolean value. Rarely used for display.

Integer Column Example

{
  "header": "RPN",
  "bindings": "rpn",
  "type": "int",
  "formula": "commonRpn",
  "width": 60
}
Formula results are automatically rounded to integers.

Float Column Example

{
  "header": "Risk Rating",
  "bindings": "riskRating",
  "type": "float",
  "format": "0.00",
  "formula": "weightedRating",
  "width": 80
}
Displays with two decimal places using the format string.

Cell Rendering and Styling

Custom Cell Renderer

Formula results can be styled dynamically using cell renderers:
{
  "header": "RPN",
  "bindings": "rpn",
  "type": "int",
  "formula": "commonRpn",
  "cellRenderer": "rpn",
  "width": 60
}
The cellRenderer references a cell decorator function that applies CSS classes based on values.

Cell Decorator Example

Define decorators in the cellDecorators configuration section:
"cellDecorators": {
  "rpn": "function(info){ var val = info.value; $(info.cell).toggleClass('boldCol', true); $(info.cell).toggleClass('rpn1', val>0 && val <= 150); $(info.cell).toggleClass('rpn2', val > 150 && val <= 350); $(info.cell).toggleClass('rpn3', val > 350); }"
}
This applies CSS classes 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

  1. In Polarion Administration, create a custom field on the work item type (e.g., “Risk Priority” on Risk type)
  2. Set field ID to match the bindings property (e.g., "rpn")
  3. Mark the field as read-only in Administration to prevent manual editing
  4. Set "readOnly": false in the column configuration to allow programmatic storage
{
  "header": "RPN",
  "bindings": "rpn",
  "type": "int",
  "formula": "commonRpn",
  "readOnly": false,
  "width": 60
}
When readOnly: false, the calculated value is saved to Polarion on each save operation.
Ensure the custom field in Polarion matches the bindings property name exactly. Field mismatch will cause save errors.

Complex Formula Examples

Conditional Status Calculation

function deriveStatus(info) {
  var rpn = info.item['rpn'] || 0;
  var approved = info.item['approved'] || false;
  
  if (!approved && rpn > 350) {
    return "CRITICAL";
  } else if (rpn > 150) {
    return "HIGH";
  } else if (rpn > 50) {
    return "MEDIUM";
  } else {
    return "LOW";
  }
}

Multi-Step Calculation with Fallbacks

function calculateWeightedScore(info) {
  var base = info.item['baseScore'] || 0;
  var severity = info.item['severity'] || 1;
  var occurrence = info.item['occurrence'] || 1;
  var adjustmentFactor = info.item['adjustment'] || 0;
  
  var score = (base * severity * occurrence) + adjustmentFactor;
  
  // Cap the score at maximum value
  return Math.min(score, 1000);
}

Performance Considerations

ConsiderationImpactMitigation
Heavy calculationsSlows grid rendering if executed on many rowsLimit formula complexity, use lazy evaluation
Missing dependenciesFormula fails if source column has null valueUse fallback values: info.item['col'] || 0
Data type mismatchesFormula returns incorrect type for column typeEnsure return type matches column type property
Circular referencesAvoided by design—formulas are read-onlySafe to reference any other column

Configuration Checklist

  • Define formula in formulas section with unique ID
  • Set column formula property to reference formula ID
  • Set column type to match formula return type (int, float, string, etc.)
  • Set column bindings to the property name where value is stored
  • Configure readOnly: true (default) unless storing in Polarion
  • (Optional) Add cellRenderer for custom styling
  • (Optional) Add format string 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
Always return null instead of 0 or empty string when no value can be calculated. This allows filtering and sorting to properly distinguish between “no value” and “value of zero”.
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.
KB ArticlesSource Code
  • AppConfigHelper.ts
  • AppConfig.ts
  • risksheet.json
  • PolarionAppConfigManager.java
  • SheetConstants.ts