cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

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

Calculation Result Discrepancy, Col Mean, etc.

Why do calculation results differ when using variables compared to using direct strings? I suspect that when variables are used, the grouping function for the variable part might not be working. How can this be resolved?

with the following formula

Col Mean(
	:data,
	:A,
	:B,
	:C_D == "ccccccc"
)

This is the formula.

Col Mean(
	:data,
	:A,
	:B,
	Column(Eval Insert("C_^get_input_1^" == get_input_2))
)
5 REPLIES 5
TamedZebra
Level III

Re: Calculation Result Discrepancy, Col Mean, etc.

Sorry, everyone. I forgot to mention that get_input_1 and get_input_2 can be assumed to be already obtained as strings, respectively.

jthi
Super User

Re: Calculation Result Discrepancy, Col Mean, etc.

First one is comparing column vs string and second one we cannot be sure what is being compared (string to string which would always be 1 or 0?). At least it isn't evaluated and you will need to evaluate the values into the formula

Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute 

-Jarmo
TamedZebra
Level III

Re: Calculation Result Discrepancy, Col Mean, etc.

I want to achieve the same result as the expression in the first line. When the variables were given as get_input_1="D" and get_input_2="cccccc" respectively, I naturally expected the same result, but the reality was different...

jthi
Super User

Re: Calculation Result Discrepancy, Col Mean, etc.

Eval(Substitute(
	Expr(Col Mean(
		:data,
		:A,
		:B,
		_input1_ == _input2_
	),
	Expr(_input1_) = NameExpr(AsColumn(dt, get_input_1)),
	Expr(_input2_) = get_input_2
	)
));

but you need to add new column and formula to that example

-Jarmo
mmarchandFSLR
Level VI

Re: Calculation Result Discrepancy, Col Mean, etc.

Column(Eval Insert("C_^get_input_1^" == get_input_2)) evaluates to Column( "C_D" == "ccccccc" ), so your formula would be

edit

Including non-string inside Eval Insert() actually causes it to evaluate to the empty string.

Col Mean(
	:data,
	:A,
	:B,
	Column( "" )
);

 

That may be why it isn't working as expected.  Jarmo's solution should be what you want.

Recommended Articles