Here is a solution. I am assuming as soon as you go over 300 you restart. If you need to stop before you go over 300, the logic change is pretty simple.
Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Cumulative_Sum_Test_Qty" );
dt << New Column( "Cumulative_Sum_Fail_Qty" );
dt:Cumulative_Sum_Test_Qty[1] = dt:Test_Qty[1];
dt:Cumulative_Sum_Fail_Qty[1] = dt:Fail_Qty[1];
holdTest = dt:Test_Qty[1];
holdFail = dt:Fail_Qty[1];
For( theRow = 2, theRow <= N Rows( dt ), theRow++,
If( dt:Cumulative_Sum_Test_Qty[theRow - 1] > 300,
dt:Cumulative_Sum_Test_Qty[theRow] = dt:Test_Qty[theRow];
dt:Cumulative_Sum_Fail_Qty[theRow] = dt:Fail_Qty[theRow];
,
dt:Cumulative_Sum_Test_Qty[theRow] = dt:Cumulative_Sum_Test_Qty[theRow - 1] + dt:Test_Qty[theRow];
dt:Cumulative_Sum_Fail_Qty[theRow] = dt:Cumulative_Sum_Fail_Qty[theRow - 1] + dt:Fail_Qty[theRow];
)
);
Jim