cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
wjalford
Level III

Need to compare result from one table with spec limit in another table. If result < limit then pass

I have a table (Limits) with the limits.  The table columns are Product, Componet A, Componet B.  Under each componet is the limit.  Example Product, Aluminum, Zinc

                                                         Fudd         .24        .50

 

I have another table FG Metals that has a PASS/FAIL column and a Aluminum column and a Zinc column with the results in each row.  Example PASS/FAIL, Aluminum, Zinc

                                                                                .09        .1

I need to compare the dt(FG metals) Aluminum .09 result with the dt(Limits) Aluminum .24.  If result is less than limit then put Pass in the PASS/FAIL column otherwise put FAIL.

 

Hopefully I explained this well enough.  Please let me know if you have any questions.  

 

Wayne

21 REPLIES 21
HSS
HSS
Level IV

Re: Need to compare result from one table with spec limit in another table. If result < limit th

Hi, Many thanks, 

 

Yes, that is what (reading Scripting Guide) I am doing now a day. :)

HSS
HSS
Level IV

Re: Need to compare result from one table with spec limit in another table. If result < limit th

Hi Nelson,

I an getting following error in the script you send me on Friday. Any help 

 

Also why do we use "__" in specs limits like LSL. I was trying to find answer in jmp script guideline but could not understand much.

 

Thanks.

 

 

Error 1.png

 

txnelson
Super User

Re: Need to compare result from one table with spec limit in another table. If result < limit th

The line of code that is having an issue, is

Column( colNamesList[theColumn] || " PASS/Fail" ) << delete formula;

The error statement is saying that it can not find the column that is being referenced.  The column being referenced should have been created in the statement just before.

dt << New Column( colNamesList[theColumn] || " PASS/Fail",
							numeric,
							CONTINUOUS,
							FORMULA( If( __LSL__ <= __col__ <= __USL__, 1, 0 ) )
						);

What is required for this statement to work, is that both an LSL and a USL exist for the column being referenced in the formula.  I suspect this is the issue.  I would check to make sure that both LSL and USL exist.

 

Concerning your question 

     "Also why do we use "__" in specs limits like LSL"

This is not a JMP requirement.  In the Substitute() function, there is a requirement to have pairs of matching values that JMP is going to use for the substitution.  I use the "__" before and after the matching values, just to make the code clear.  I also give the name of the matching pair something meaningful.  And in this case, the Substitution() function is substituting the LSL, the reference Col and the USL, and so by my convention, I use, __LSL__, __col__ and __USL__.

Jim
HSS
HSS
Level IV

Re: Need to compare result from one table with spec limit in another table. If result < limit th

Hi,

 

I did that check and made sure that LSL and USL both should be there in specs table. In fact, I also start the For loop -- the Column = 10 where I knew that from column 10th onward, I have specs limits in the table, though it should be taken care by Is Empty statement.

 

Nothing worked.

 

Thanks.

 

txnelson
Super User

Re: Need to compare result from one table with spec limit in another table. If result < limit th

The Manage Spec Limits, may not be finishing before the code below is processing.  Try running just through the Manage Spec Limits.  Then once it is complete, run the remaining code.

 

Also, add 

show(colNamesList[theColumn] || " PASS/Fail");

Just before line 19

		Eval(

Then take a look at what name the code is complaining about

Jim
HSS
HSS
Level IV

Re: Need to compare result from one table with spec limit in another table. If result < limit th

Hi, Yes it is working if I am running code till manage spec limit first and then the rest of it, And adding 

 

show(colNamesList[theColumn] || " PASS/Fail");     does  not make any difference. Code is still not running in one go, even after adding this line. 

 

Is there any way I can force to evaluate manage specs limit part first and then move further or can I put some wait (say - 2 sec) commend before going into the for loop ?

 

Thanks.

 

txnelson
Super User

Re: Need to compare result from one table with spec limit in another table. If result < limit th

You can add a 

wait(0);

or

dt << rerun formulas;

 

Jim
HSS
HSS
Level IV

Re: Need to compare result from one table with spec limit in another table. If result < limit th

dt << rerun formulas; and  wait (0)   - none of them is working for me. But yes, if I split my code in two runs -- it is working fine.

 

Any other suggestion ?

 

HSS
HSS
Level IV

Re: Need to compare result from one table with spec limit in another table. If result < limit th

Whatever the wait time I am putting, it just evaluate only first column and through the same error. But, if I split and run it in two parts -- it is fine ! No idea why ?

 

 

HSS
HSS
Level IV

Re: Need to compare result from one table with spec limit in another table. If result < limit th

Hi TxNelson,

 

In the script, if I comment out -- Column( colNamesList[theColumn] || " PASS/Fail" ) << delete formula; it is running fine.

Just a query -- are we not deleting the column formula, even before we are getting our column? As our column will be complete

once we will substitute the values of LSL and USL and we are doing in in the next line of For loop ?

colNamesList = dt << get column names(string,continuous);

For( theColumn = 1, theColumn <= N Items( colNamesList ), theColumn++, 

	Clear Symbols( specs );
	specs = Column( dt, colNamesList[theColumn] ) << get property( "Spec Limits" );
	If( Is Empty( specs ) == 0, /*show(colNamesList[theColumn] || " PASS/Fail"), Wait (1); */
		Eval(
			Substitute(
					Expr(
		
						dt << New Column( colNamesList[theColumn] || " PASS/Fail",
							numeric,
							CONTINUOUS,
							FORMULA( If( __LSL__ <= __col__ <= __USL__, 1, 0 ) )
						);
						/* Column( colNamesList[theColumn] || " PASS/Fail" ) << delete formula;*/
					),
				Expr( __LSL__ ), specs["LSL"],
				Expr( __col__ ), Parse(":" || colNamesLIst[theColumn] ),
				Expr( __USL__ ), specs["USL"]
			)
		)
	);
);