cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

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

Trying to create a column and fill it with a formula but I get an error.

View more...
Hi, I can make the script to fill the new column created.

This is the error I get:
 Has anyone an idea of whats wrong here?


Formula Interrupted
Cannot convert argument to a number [or matrix] at row 1 in access or evaluation of 'Subtract' , Column( j ) - /*###*/Column( j + 1 ) /*###*/
Formula evaluation errors have been ignored
For (j=3, j<=10, j=j+2,
	
	ColLen=Length(Char(Column name (j)));
	ColName=Left (Char(Column Name(j)),ColLen -5);
	NewCol=Substr(ColName,6);
	
	New Column(
		"Delta: "||NewCol,
		Numeric,	
		Formula (
			(Column (j)- Column(j+1))
		)
	)
);
13 REPLIES 13
CrownofTears
Level II

Re: Trying to create a column and fill it with a formula but I get an error.

Just As Column() instead of column worked!

mmarchandTSI
Level V

Re: Trying to create a column and fill it with a formula but I get an error.

@CrownofTears, Based on your original JSL:

 

For( j = 3, j <= 10, j = j + 2, 
	
	ColLen = Length( Char( Column Name( j ) ) );
	ColName = Left( Char( Column Name( j ) ), ColLen - 5 );
	NewCol = Substr( ColName, 6 );
	
	Eval(
		Eval Expr(
			New Column( "Delta: " || NewCol,
				Numeric,
				Formula( (As Column( Expr( Column Name( j ) ) ) - As Column( Expr( Column Name( j + 1 ) ) )) )
			)
		)
	);
);

I like the clean As Column("column name") functions, and it's not ugly like my Eval( Parse(...) ) solution.

CrownofTears
Level II

Re: Trying to create a column and fill it with a formula but I get an error.

Just As Column() instead of column worked!

hogi
Level XIII

Re: Trying to create a column and fill it with a formula but I get an error.

Seems to work "once" (the values are OK)  - but (at least for my test case) variant #1 reports an error with the formula when you open it afterwards:

hogi_0-1691781905300.png

 

Variant # 6 seems to solve this issue:

hogi_1-1691782023921.png

but it will definitely fail once Jmp is closed and forgets what dt means ....

Recommended Articles