Choose Language Hide Translation Bar
Highlighted
BHarris
Level V

Select last point in each run

Suppose I have columns:  run_id, time, distance

 

... and I want to just select the rows with the last time for each run_id.  How do I do that?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
BHarris
Level V

Re: Select last point in each run

Is this pretty typical in JMP, to create formula columns to look for certain conditions then select based on that?
I played around for a minute after writing this question and ended up with this formula column: Col Maximum ( :Name( "time(s)" ), :run_id ) - :Name( "time(s)" )
... then I just click on one of the rows with "0" and then did a "select matching". I was hoping there was an easier way, like making a summary table with max(time) grouped by run_id, then let me select the rows there, but those rows were selecting all of the data from which the max was calculated, not just the rows that held the max value.

View solution in original post

3 REPLIES 3
Highlighted

Re: Select last point in each run

You can create an indicator column using a formula. Be sure to sort (nested) by run_id and time first. The formula would be a simple Boolean result. Use the Lag() function as such: If( :run_id == Lag( :run_id, -1 ), 0, 1 ). Then you can select the rows where this column equals 1.

Learn it once, use it forever!
Highlighted
BHarris
Level V

Re: Select last point in each run

Is this pretty typical in JMP, to create formula columns to look for certain conditions then select based on that?
I played around for a minute after writing this question and ended up with this formula column: Col Maximum ( :Name( "time(s)" ), :run_id ) - :Name( "time(s)" )
... then I just click on one of the rows with "0" and then did a "select matching". I was hoping there was an easier way, like making a summary table with max(time) grouped by run_id, then let me select the rows there, but those rows were selecting all of the data from which the max was calculated, not just the rows that held the max value.

View solution in original post

Highlighted
txnelson
Super User

Re: Select last point in each run

Just to add something that I hope is obvious to all......for @markbailey code to work, the data table needs to be sorted ascending on columns run_id and time
Jim
Article Labels

    There are no labels assigned to this post.