cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Get the free JMP Student Edition for qualified students and instructors at degree granting institutions.
Choose Language Hide Translation Bar
View Original Published Thread

Using variables to create formula columns

rmeredith
Level I
For( i = 1, i <= N Items( allm ), i++,
	m = allm[i];
	name = "Peak Mass " || Char( m );
	del = Current Data Table() << delete columns( Char( name ) );
	(New Column( Char( name ), set formula( If( subtract(eval(m), 3) < :deltamass <= add(eval(m),3), :pctrelative, 0 ) ) ) ; 
	If( Contains( name, "Peak Mass 0" ),
		del
	) ; );
);

Help! I have tried like 5 things, and I can't get my variable to spit out it's numerical value into the column formula. 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Using variables to create formula columns

Most likely something like this:

	Eval(EvalExpr(New Column(Char(name), set formula(If(Subtract(Expr(m), 3) < :deltamass <= Add(Expr(m), 3), :pctrelative, 0))));

Wrap New Column() with Eval(EvalExpr()) and replace Eval with Expr() inside it.

-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User


Re: Using variables to create formula columns

Eval(EvalExpr()) should do the trick

-Jarmo
rmeredith
Level I

Re: Using variables to create formula columns

Just suck in where I currently have eval(m)? I just tried that and it is still just putting "Eval Expr(eval(m))" into the column function rather than the numerical value of m.

This post originally written in German and has been translated for your convenience. When you reply, it will also be translated back to German.

jthi
Super User

Re: Using variables to create formula columns

Most likely something like this:

	Eval(EvalExpr(New Column(Char(name), set formula(If(Subtract(Expr(m), 3) < :deltamass <= Add(Expr(m), 3), :pctrelative, 0))));

Wrap New Column() with Eval(EvalExpr()) and replace Eval with Expr() inside it.

-Jarmo