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
OC200m
Level II

Creating A column in new table, filling with value under one condition, and another if otherwise

Hi all, building my own table from a number of others, and making a column that I want to have fixed length. If a column exists from another table, I wish to fill it with values made from a list , if not, i wish to fill it with zeroes. Currently, there are no values appearing and I cannot figure out a place to put the if statements that will make this work out. This is my most recent attempt, Idea is to fill with values from the array N_4, which is populated if that column name exists, else fill with zeroes, but I'm not sure if this is the correct way to do it, any pointers would be welcomed! 

New Column( "N(4)",Numeric, formula(If( Contains( Data Table( "Counter Bin Summary" ) << get column names( string ), "N(4)" ) ,Values(N_4),Set Each Value (0)) )),
	

 

1 REPLY 1
txnelson
Super User

Re: Creating A column in new table, filling with value under one condition, and another if otherwise

I would change the code a bit, and not place the IF() into a column formula, but rather, do the comparison in open code, and then create the column based upon the results of the IF().

If( Try( Data Table( "Counter Bin Summary" ):"N(4)"n << get name, "" ) != "",
	theValues = Data Table( "Counter Bin Summary" ):"N(4)"n << get values;
	Data Table( "New Table" ) << New Column( "N(4)" );
	Data Table( "New Table" ):"N(4)"n << set values( theValues );
,
	Data Table( "New Table" ) << New Column( "N(4)", set each value( 0 ) )
);

Please note that I am referencing your new table by the name "New Table"  This needs to be changed to whatever the new tables name actually is.

Jim