Use the function to find the first position of the weight column in the top 5 rows greater than 120.
Excuse me, Thanks!
Here is one way to do it</CODE></P> <DIV> <PRE><CODE class=" language-jsl">Names Default To Here( 1 ); dt = Open( "$SAMPLE_DATA/big class.jmp" ); dt << New Column( "match", formula( value = .; If( Row() > 5, count = 0; For( i = Row() - 5, i <= Row() - 1, i++, count++; If( :weight[i] > 120, value = count; Break(); ); ); ); value; ) );
</CODE></P> <DIV> <PRE><CODE class=" language-jsl">Names Default To Here( 1 ); dt = Open( "$SAMPLE_DATA/big class.jmp" ); dt << New Column( "match", formula( value = .; If( Row() > 5, count = 0; For( i = Row() - 5, i <= Row() - 1, i++, count++; If( :weight[i] > 120, value = count; Break(); ); ); ); value; ) );
</CODE></PRE> <DIV> </DIV> <PRE><CODE class=" language-jsl">
The JSL function that here corresponds to Excel's Match() would be Loc(). However, Loc() returns a matrix with the position of all matches, not just the first (or last).
Example:
dt << New Column("match", formula(If(Row() > 4, Loc(:weight[Row() - 4 :: Row()] > 120)[1])) );