- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Is there an alternative to iterating through rows using column formula?
I have a dataset which is a series of test runs, all collected in one table. The experiment is 6 sweeps from high to low speed for each sample, and what I need to do is assign the correct sweep number to each one (i.e. from 1 to 6) and then restart the sequence for the next sample. I could easily do this with the sequence or count function, however the number of points in each sweep is not always the same, it varies around 24-26. See image below for an example of one "sweep" from high to low speed before starting the next one.
I'm sure this could be done with a script, however my experience in that area is minimal. Is there a quick and dirty way of doing it using column formulas?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Is there an alternative to iterating through rows using column formula?
Lag() could be helpful here.
Replace :Column 1 with your speed column:
If(Row() == 1, curVal = 1);
If(:Column 1 > Lag(:Column 1),
curVal += 1
);
curVal;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Is there an alternative to iterating through rows using column formula?
Lag() could be helpful here.
Replace :Column 1 with your speed column:
If(Row() == 1, curVal = 1);
If(:Column 1 > Lag(:Column 1),
curVal += 1
);
curVal;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Is there an alternative to iterating through rows using column formula?
Thanks for the help, that worked for each set of 6 runs of each sample. I added an extra line in to bring the counter back to 1 after each 6 sweeps so the below formula and code assigns the right sweep number with all the data stacked in one table!
If( Row() == 1, curVal = 1 );
If( :speed > Lag( :speed ),
curVal += 1
);
If( curVal > 6, CurVal = 1 );
curVal;