Choose Language Hide Translation Bar
Highlighted
ducduy9104
Level I

How Formula works in New Column Function

Hi everyone,

 

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
New Column("Sum",
"Numeric",
"Continuous",
Set Formula(If(Row() == 1, :Height, Lag(:Sum,1) + :Height))
);

The code above creates Sum column with calculated the accumulative sum. I am new to JSL so could someone explain me how the Formula command works. Is it scan one by one row in the column so that we can write :Height instead of constructing a For-loop with [i] which indicates the position of the current rows.

And have any other ways to do this cumsum?

 

 


Tks everybody and have a good day!

 

1 REPLY 1
Highlighted
txnelson
Super User

Re: How Formula works in New Column Function

Formulas do loop through each row, applying the given formula to the values from each row.  You can read the documentation on formulas in the "Using JMP" document

     Help==>Books==>Using JMP

An alternative version of your formula could be expressed as

dt<<new column("sum",formula(
Col Cumulative Sum( :height)));
Jim
Article Labels

    There are no labels assigned to this post.