I would like to use DS Code to calculate a reducing or increasing balance column as shown in the attached file column S.
This column R would start by reading a starting balance from the column O only if column U = 1
The second record would then Use the value in column R record 1, Increase/reduce this value by the value, if any, in column O and place the result in column R
The third record would then repeat this
Until the next value of 1 is found in Column U when the loop would start again..
Repeating until EOF.
if U=1 then =O2 |
If U=0 and O3<0 then R2+O3 Else R2 |
If U=0 and O4<0 then R3+O4 Else R3 |
If U=0 and O5<0 then R4+O5 Else R4 |
If U=0 and O6<0 then R5+O6 Else R5 |
If U=1 then O7 |
If U=0 and O8<0 then R7+O8 Else R7 |
If U=0 and O9<0 then R8+O9 Else R9 |
A | B | C | O | R | S | T | U | V |
MATERIAL | PLANT | QUANT_B | STOCK_QTY | CARRY_FORWARDS_VOL | FIRST_MAT_PLANT | FIRST_RECORD | LAST_RECORD | |
15786 | 1051 | 220 | 0 | 0 | if U=1 | 1 | 1 | 0 |
15786 | 1051 | -220 | 220 | -220 | If U=0 | 0 | 0 | 0 |
15786 | 1051 | 220 | 220 | -220 | If U=0 | 0 | 0 | 0 |
15786 | 1051 | -220 | 220 | -440 | If U=0 | 0 | 0 | 0 |
15786 | 1051 | 20 | 0 | -440 | If U=0 | 0 | 0 | 1 |
15786 | 1051 | 240 | 20 | 20 | If U=1 | 0 | 1 | 0 |
15786 | 1051 | -240 | 260 | -220 | If U=0 | 0 | 0 | 0 |
15786 | 1051 | 240 | 260 | -220 | If U=0 | 0 | 0 | 0 |
15786 | 1051 | -240 | 260 | -460 | 0 | 0 | 0 | |
15786 | 1051 | -20 | 20 | -480 | 0 | 0 | 1 |
Is this possible?