@UserID16644, if your :Column2 ever has the same value again, you'll get undesired results.
New Table( "Untitled 155",
Add Rows( 12 ),
New Column( "Column 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [10, 2, 5, 3, 2, 1, 3, 4, 6, 2, 5, 3] )
),
New Column( "Column 2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [20, 20, 20, 20, 15, 15, 15, 15, 20, 20, 20, 20] )
),
New Column( "Result",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If(
:Column 2 != Lag( :Column 2 ) | Row() == 1, :Column 1,
Row() == 2 | Lag( :Column 2, 2 ) != :Column 2,
:Column 2 - Lag( :Column 1 ),
Lag( :Result ) - Lag( :Column 1 )
)
)
),
New Column( "Result 2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( Row() == Col Min( Row(), :Column 2 ),
:Column 1,
(:Column 2 - Col Cumulative Sum( :Column 1, :Column 2 )) + :Column 1
)
)
)
)