Skip to main content
This gem runs in .
Use the RunningTotal gem to calculate running totals for selected numeric columns. You can also configure optional partitioning and row ordering for the calculation. This gem is useful when you want to control how running total calculations are grouped and ordered across your data.

Prerequisites

  • Add prophecy_basics package version 1.0.11 or higher to your project.

Parameters

ParameterDescription
Columns for running totalSelect the columns to include in the running total calculation.
Partition by (optional)Optionally select fields to partition the calculation.
Order rows for calculation (optional)Configure how rows are ordered for the calculation. This section includes Order By Columns and Sort strategy.
Output column prefix (optional)Enter a prefix for the output columns.

Order rows for calculation

Use Order By Columns to select the columns used to order rows for the calculation. Use Sort strategy to choose one of the following options:
  • ascending nulls first
  • ascending nulls last
  • descending nulls first
  • descending nulls last

Example

Let’s say you have the following dataset.
RecordValue
A10
B12
C4
If you select Value in Columns for running total, the gem calculates a cumulative total across the rows.

Result

RecordValueRunningTotal_Value
A1010
B1222
C426