Skip to content

Pct change


Calculate percentage change between consecutive numbers in a numeric column.

For a pair of consecutive numbers x1, x2 in the input column, calculates the difference between x2 and x1 expressed as a percentage of x1, i.e. 100 * (x2 - x1) / x1.


The following are the step's expected inputs and outputs and their specific types.

    data: number,
    *sort: column, 
        "param": value
) -> (output: number)

where the object {"param": value} is optional in most cases and if present may contain any of the parameters described in the corresponding section below.


data: column:number

A numeric column to calculate percentage change for.

*sort: column

An optional column used to sort the rows before calculating the percent change.


output: column:number

A numeric column with the calculated percentages.


fill_nan: string = "forward"

Method to fill missing values (NaNs). When forward, uses last valid observation to fill a gap. When backwards, uses next valid observation instead.

Must be one of: "forward", "backward"

fill_nan_max: integer | null

Maximum number of consecutive NaNs to fill before stopping.

Range: 1 ≤ fill_nan_max < inf

as_proportion: boolean = False

Whether to express result as proportion instead of percentage.

ascending: boolean = True

Whether to sort ascending instead of descending using the sort column before calculating the change.