cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Due to global connectivity issues impacting AWS Services, users may experience unexpected errors while attempting to authorize JMP. Please try again later or contact support@jmp.com to be notified once all issues are resolved.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
SMW
SMW
Level II

JMP Scripting - New Column Function and Multiple Formula Functions Don't MIX !!!! Interesting Problem !!!!

Hello Community

 

I have written a script in which I search an open data table for rows which contain text A in column 2 AND text B in column 3.  Using the row numbers, I then save the text from column 7 for all of those rows to a new individual variable.  The problem is I would like to then save the text in column 7 for all those rows in a NewTable with a New Column.  The first column was not a problem as I just list the pairs of texts.

 

However, I am having a lot of trouble making a New Column containing the text for column 7 of the identified rows.  Its something like this.

 

Col 2 Col3 ..... Col7

Hair   Red        Pass

Hair   Blue       Pass

Clown Sad      Pass

Clown Joke     Fail

 

A= dt << get rows where(contains(as column(2),"Hair")
& (contains(as column(3),"Red");

B= dt << get rows where(contains(as column(2),"Clown")
& (contains(as column(3),"Joke");

HairPassFail = (column(7)[A]);

ClownPassFail = (column(7)[B]);

New Table( "Table",Add Rows( 2 ),
      New Column( "TextPairs",Character,"Nominal",
                 Set Values({"Hair-Red","Clown-Joke"})),
      New Column( "PASS/FAIL",continuous,"Nominal", formula(HairPassFail),formula(ClownPassFail))
);

When I show Hair and ClownPassFail, they output the text Pass and Fail respectively. My problem is that as I add new formulas into the New Column for each corresponding rows from the first new colum, the entire column gets overwritten. This is in 10 conditions now 2 for simplicity. So in this example, the output would be

Col1            Col2

Hair-Red     Fail 

Clown-Joke Fail

Instead of Hair-Red Pass.

 

Does anyone have any advice as to how I can create a new column where each successive value is a unique formula variable from the series of rows ?

 

There must be a much easier way to do this I'm sure. 

 

Thanks !!!!

 

 

 

2 REPLIES 2
Craige_Hales
Super User

Re: JMP Scripting - New Column Function and Multiple Formula Functions Don't MIX !!!! Interesting Problem !!!!

A formula column can only have one formula. Usually the formula uses values of other columns on the same row to produce a value.

Craige
pauldeen
Level VI

Re: JMP Scripting - New Column Function and Multiple Formula Functions Don't MIX !!!! Interesting Problem !!!!

You can just built your textpairs column by doing a concatenation of the first two columns. Then for your Pass/fail column you can built an if statement looking at the texpairs column and if the textparis row matches a condition, copy pass/fail column in the cell. Does this need to be scripting or would simple column formulas suffice? if so, share a part of your data table.

Recommended Articles