- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How to Get Row Number When There is Missing Data
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 |
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Get Row Number When There is Missing Data
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
)
)
)
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Get Row Number When There is Missing Data
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
)
)
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Get Row Number When There is Missing Data
It works.
Thank you.