Skip to content

pct

Input Stack:
expr: TimeSeriesExpr
Output Stack:
TimeSeriesExpr

Calculate the percentage contribution of each time series to the total across all series. Each individual time series value is divided by the sum of all series at that timestamp, then multiplied by 100 to get a percentage. This is useful for understanding the relative contribution of each component to the total.

This operator is equivalent to: :dup,:dup,:sum,:div,100,:mul

The operation: 1. Duplicates the input expression twice 2. Sums all series together to get the total 3. Divides each individual series by the total 4. Multiplies by 100 to convert to percentage

Parameters

  • expr: The time series expression (typically grouped data) to calculate percentages for

Examples

Basic percentage calculation:

name,sps,:eq,
(,nf.cluster,),:by,
:pct

Comparing before and after percentage conversion:

BeforeAfterStack to 100%
name,sps,:eq,
(,nf.cluster,),:by
name,sps,:eq,
(,nf.cluster,),:by,
:pct
name,sps,:eq,
(,nf.cluster,),:by,
:pct,
:stack
  • :div - Manual percentage calculation with custom divisors
  • :sum - Get totals used in percentage calculation
  • :stack - Display percentages as cumulative areas
  • :by - Group data before calculating percentages