cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
ReginaHong
Level III

JSL fill to end of table using first row value

Hi,

 

Using JSL script, I want the first cell value in "Intercept" column to Fill to end of table with the same value in first cell. Can anyone show me how to write it in script?

 

Capture.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp
Staff

Re: JSL fill to end of table using first row value

I think the answer depends on what else is happening within your JSL, and how you want a user (assuming there is one) to interact with this. You can do something like:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "X" );
dt:X[1] = 5;
dt << New Column( "X2", Formula(if(Row() == 1, :X, Lag(:X2, 1))));
dt << runFormulas;
Wait(2);
dt:X[1] = 10;
dt << runFormulas;

but that doesn't seem very useful. Because a formula column is computed, JMP will not allow you to edit one of the cells therein.

View solution in original post

4 REPLIES 4
ian_jmp
Staff

Re: JSL fill to end of table using first row value

Using 'Help > Scripting Index' is good for this kind of thing. In this case, the example is:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "X" );
dt:X << Set Each Value( 5 );
ReginaHong
Level III

Re: JSL fill to end of table using first row value

Hi Ian,

 

What if my value in first row can change from time to time instead of having a fix value? Can I script it in a way that it will always use the first row value (not a fix value) to fill up the rest of the rows in that column?

ian_jmp
Staff

Re: JSL fill to end of table using first row value

I think the answer depends on what else is happening within your JSL, and how you want a user (assuming there is one) to interact with this. You can do something like:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "X" );
dt:X[1] = 5;
dt << New Column( "X2", Formula(if(Row() == 1, :X, Lag(:X2, 1))));
dt << runFormulas;
Wait(2);
dt:X[1] = 10;
dt << runFormulas;

but that doesn't seem very useful. Because a formula column is computed, JMP will not allow you to edit one of the cells therein.

andersonmj2
Level IV

Re: JSL fill to end of table using first row value

Ian is correct in his answer to your question.  I have at times wanted to do the OTHER thing in the menu image you showed (Fill to row ...), which is also pretty simple by just using the Row Index functions to select the cells you want to fill.

 

dt << Select Where( Any( Row() == Index( 7, 10 ) ) );