How to create a cumulative subtract down a column (Subtract Running Totals)

Knowledge Drop

Last tested: Mar 11, 2021

The Problem

If I want to perform a cumulative subtracting with the current cumulative row value minus the next row value with table calculation?

Solution:

One options is to use the following

sum(offset_list(

if( row() = 1, ${users.average_age},-${users.average_age} )

,

1-row(),

row()

)

)

The outcome in the Explore UI will look like this:

As we use so many functions combined here, I would suggest to look them up in our docs here for more context.