There is missing value in my data.
I'm trying to create script for new column 'Row Number' to get row number of lagged value of Col1(non-missing data).
I'm facing problem when missing data is encountered.
Below is my data with required row number outcome.
How to create script for this?
| Row# | Col1 | Row Number(outcome) |
| 1 | 11 | |
| 2 | 18 | 1 |
| 3 | 34 | 2 |
| 4 | 3 | |
| 5 | 3 | |
| 6 | 3 | |
| 7 | 20 | 3 |
| 8 | 7 | |
| 9 | 7 | |
| 10 | 24 | 7 |
| 11 | 14 | 10 |
| 12 | 17 | 11 |
| 13 | 12 | |
| 14 | 12 | |
| 15 | 16 | 12 |
| 16 | 25 | 15 |
I think this will do what you're looking for. Lag() without an argument will give the lag of the current column.
New Column( "r",
Formula(
If(
Row() == 1, .,
Is Missing( Lag( :Col1 ) ), Lag(),
Row() - 1
)
)
)
I think this will do what you're looking for. Lag() without an argument will give the lag of the current column.
New Column( "r",
Formula(
If(
Row() == 1, .,
Is Missing( Lag( :Col1 ) ), Lag(),
Row() - 1
)
)
)
It works.
Thank you.