Here is my solution, however, it does not match your solution. I believe your calculations as shown are incorrect for Row 3. See my script, which includes your sample data table.
Names Default To Here( 1 );
dt = New Table( "Example",
Add Rows( 4 ),
New Column( "R",
Numeric,
"Continuous",
Set Values( [., 1.4, 1.67, 2.3] )
),
New Column( "Cases",
Expression,
"None",
Set Values( {[1, 1, 2, 1], Empty(), Empty(), Empty()} )
)
);
// The calculation script
casesSum = 0;
For(i=2,i<=nrows(dt),i++,
Eval( Eval Expr( casesMatrix = Expr( :cases[i - 1] ) ) );
:R[i] = :R[i] * (1 - (Sum( casesMatrix )+casesSum) * 4 / 100);
:Cases[i] = casesMatrix * :R[i];
casesSum = casesSum + sum(casesMatrix);
);
// Row 3 R does not seem to be correct
// I can not come up with .71, I come up with .96192
show(1.4 * (1 - (5 * 4/100)) );
show(1.67 * (1 - (10.6 * 4/100)) );
txnelson_0-1711546109146.png
Jim