Skip to content

Calculated Metrics

Calculated metrics let you create your own indicators based on existing metrics using mathematical formulas.

Formula syntax

A formula is written as a string using:

  • Existing metric names in square brackets: [clicks], [cost]
  • Arithmetic operators: +, -, *, /
  • Parentheses for grouping: (, )
  • Functions: ROUND(), ABS(), IF()

Formula examples

CPC:        [cost] / [clicks]
CPL:        [cost] / [leads]
ROAS:       [revenue] / [cost] * 100
Profit:     [revenue] - [cost]
Margin:     ([revenue] - [cost]) / [revenue] * 100

Configuration

A calculated metric is defined as an object in the calculated_metrics array:

json
{
  "calculated_metrics": [
    {
      "name": "CPL",
      "formula": "[cost] / [leads]",
      "type": "money",
      "description": "Cost per lead",
      "format": "decimal_2"
    }
  ]
}
FieldTypeRequiredDescription
namestringYesA unique metric name
formulastringYesThe mathematical formula
typestringNoResult type: float, money, percentage, integer
descriptionstringNoMetric description for the interface
formatstringNoFormat: decimal_0, decimal_1, decimal_2, percent_1, percent_2

Available functions

FunctionDescriptionExample
ROUND(value, decimals)RoundingROUND([cpc], 2)
ABS(value)Absolute valueABS([profit])
IF(condition, true_val, false_val)Conditional expressionIF([clicks]>0, [cost]/[clicks], 0)

Conditional logic

The IF function supports comparison operators: >, <, >=, <=, ==, !=:

json
{
  "name": "CPC with division-by-zero protection",
  "formula": "IF([clicks] > 0, [cost] / [clicks], 0)"
}

Calculation order

  1. First, all standard metrics are pulled
  2. Then filters and groupings are applied
  3. Calculated metrics are computed last, based on the already-grouped data
  4. This means a calculated metric can't reference another calculated metric

Limitations

  • A maximum of 10 calculated metrics per report
  • A formula can't exceed 50 characters
  • A formula can only reference metrics already added to the report
  • Nested calculated metrics are not supported

Maintained by the LightLead Documentation Team · Last verified: 2026-07-25