cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
gandi2223
Level III

Add new column with formula to data table at certain position

Is it possible to add a new column to a data table (a) at a certain position (e.g. after a particular column) and (b) assign it a formula?

The New Column command can do (a) and the Add Multiple Columns command can do (b), but is there a way to get both done in one go?

Something like the command below (which does not give the desired result, however):

dt << New Column( "NewCol",

  After(:Col3),

  Numeric,

  Continuous,

  Format( "Best", 5 ),

  Formula( :Col3 * 2 )

);

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp
Level X

Re: Add new column with formula to data table at certain position

I think you need a couple of steps:

 

 

dt = Open("$SAMPLE_DATA/Big Class.jmp");
WAit(2);
dt << NewColumn("BMI", Numeric, Continuous, Formula(:weight/:height^2));
Wait(2);
dt << MoveSelectedColumns({:BMI}, After(:sex));

 

View solution in original post

3 REPLIES 3
ian_jmp
Level X

Re: Add new column with formula to data table at certain position

I think you need a couple of steps:

 

 

dt = Open("$SAMPLE_DATA/Big Class.jmp");
WAit(2);
dt << NewColumn("BMI", Numeric, Continuous, Formula(:weight/:height^2));
Wait(2);
dt << MoveSelectedColumns({:BMI}, After(:sex));

 

mdawson69
Level IV

Re: Add new column with formula to data table at certain position

I think you have your a and b mixed up. Add Multiple Columns permits you to add the new columns at a specific point relative to other columns—Before First, After Last, or after a select column—and is otherwise quite limited with what you can preset for the new columns. New Column will permit you to set any number of column properties such as a formula, but lacks a parameter for placement. As Ian suggested, the way to achieve what you want is to define the new column using New Column then use Move Selected Columns to place the column in the data table.

gandi2223
Level III

Re: Add new column with formula to data table at certain position

True!