cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

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

Last column,Col Value(NCol()-1)

I have data tables where the number of columns vary, but the last column in each table holds information such as "PASS" and "FAIL" where I want to create a new column in each table where if it is PASS then replace with numeric 1, and Fail numeric 0 with an IF statement. 

I tried

New column with formula Col Value(NCol()-1) and it does not work.   If I replace with a hard coded column value e.g., Col Value(9) it returns the pass/fail and I can use an IF statement to change to the numeric values, but I really need the NCol()-1 to paste into all the tables as the last column. 

How do I make the formula work?

IF (Col Value(NCol()-1) = "PASS", 1, 0);

 

5 REPLIES 5
jthi
Super User

Re: Last column,Col Value(NCol()-1)

I don't really suggest doing something like this, but the formula would most likely look something like this

If(Column(N Col() - 1)[Row()] == "PASS",
	1,
	0
)

or

If(As Column(N Col() - 1) == "PASS",
	1,
	0
)
-Jarmo
Thierry_S
Super User

Re: Last column,Col Value(NCol()-1)

Hi,

You have to specify a

If(  Col Value( Column( N Col() - 1 ) )== "PASS"),
	1,
	0
)

column in your formula as shown below:

 

Thierry R. Sornasse
justvince
Level III

Re: Last column,Col Value(NCol()-1)

I found the solution using EVAL()

If( Col Value( Eval( N Col() - 1 ) ) == "PASS", 1, 0)
hogi
Level XIII

Re: Last column,Col Value(NCol()-1)

@jthi 's approach is better documented.

Can someone explain what col value() does, or share a link to the documentation?

Wow, Eval() works?

Col Value in Formula Editor:

hogi_1-1767820776908.png

Hover Tip in Formula Editor: nothing

hogi_0-1767820734502.png
hogi
Level XIII

Re: Last column,Col Value(NCol()-1)

 

dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
:height << 	Set Property( "Missing Value Codes", {59} );

row()=1;
Show(col value("height")); //.
as column("height"); //. Show(col stored value("height")); // 59 // accepts strings, columns, names ... as argument
//row=40 Show(col value("height",40)); Show(col value(:height,40)); Show(col value(5,40)); Show(col value(Column("height"),40));
Show(col value(As Column("height"),40)); As Column("height")[40]; // doesn't accept Expressions -> fix via Eval Show(col value(2+2)); // ␀

 

 

Recommended Articles