I'm trying to write a formula in Col3 that adds the current value of Col1 with the lagged value of Col2 but I'm running into a pickle trying to figure out how to carry forward the last observation from Col2 when missing data is encountered and to use this value at the first instance of non-missing data. That is,
If( !IsMissing( Col1)
Col1 + Lag(Col2,1);
//create variable that contains current Col2 value;
//Else
Col1 + previously stored value from Col2;
);
I would appreciate any suggestions on how best to accomplish this. Thanks.
| Row# |
Col1 |
Col2 |
Col3 |
|---|
| 1 |
2 |
1 |
|
| 2 |
1 |
3 |
2 |
| 3 |
1 |
5 |
4 |
| 4 |
2 |
7 |
7 |
| 5 |
. |
. |
|
| 6 |
. |
. |
|
| 7 |
. |
. |
|
| 8 |
2 |
8 |
9 |
| 9 |
2 |
9 |
10 |
| 10 |
1 |
11 |
10 |
| 11 |
. |
. |
|
| 13 |
. |
. |
|
| 14 |
2 |
12 |
13 |
| 15 |
2 |
13 |
14 |
| 16 |
1 |
14 |
14 |
| 17 |
2 |
15 |
16 |