cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to get limits from from column and use it for other columns via JSL?

The attached data table has got limits (LSL/USL) for each measured parameter (Current, Resistance) in the respective columns. 

Without changing the data table format, how do I get the limits for each parameter to show as reference lines for example when the Median is plotted vs PartID (as in the script in the attached data table)?

One way I can think of doing this is to save the LSL/USL into the column properties spec limits for each parameter and show them as reference lines, but I need some JSL help for this. This would be my preferred way.

Add Spec Limits () is another option, but I guess, I will need to do this for each measured parameter and  in my actual data (attached is example data) the number of measured parameters is ~50, so this route is not preferable. 

 

When it's too good to be true, it's neither
1 ACCEPTED SOLUTION

Accepted Solutions
Neo
Neo
Level VI

Re: How to get limits from from column and use it for other columns via JSL?

@txnelson @jthi 

Thanks, I will try your solution now. I wanted to do something similar but cannot get the following function to work. The idea is to apply this to a column group after grouping all the tested parameter columns. I tried it for one tested parameter (Current) column but it did not work. Works fine when numbers are passed for limits but not when variables are passed. Where did I go wrong (I have tried w & w/o Eval() and Expr()).

Names Default To Here( 1 );

setSpecLimits = Function( {dt_ref, colName, _LSL, _USL},
	{specLimits}, 

	tmp = Eval( Expr( dt_ref:colName << Set Property( "Spec Limits", {LSL( _LSL ), USL( _USL ), Show Limits( 1 )} ) ) );
	Return( specLimits ); //optional
);

////Check
Clear Log();
//test before
specLims = Data Table( "exampleData" ):Current << Get Property( "Spec Limits" ); Show( specLims ); 

//New values
_LSL = Data Table( "exampleData" ):Current[2]; Show( _LSL );
_USL = Data Table( "exampleData" ):Current[3]; Show( _USL );
dt_ref = Data Table( "exampleData" ); show (dt_ref);
colName = "Current"; Show( colName );

//call function
setSpecLimits( dt_ref, colName, _LSL, _USL ); 

//test after
specLims = Data Table( "exampleData" ):Current << Get Property( "Spec Limits" ); Show( specLims ); 

When it's too good to be true, it's neither

View solution in original post

11 REPLIES 11
jthi
Super User

Re: How to get limits from from column and use it for other columns via JSL?

Easiest (and in my opinion the best) would be to change the table format but as you cannot do that, then the other options would be using column properties (this would be a bit weird as you would have limits for limits) or graphic script. First you would have to collect all the possible limits for each of the columns (can there be different limits for same columns?), summary should work quite well for this, and then depending on your choice either add then as column properties or use then with graphic script.

-Jarmo
txnelson
Super User

Re: How to get limits from from column and use it for other columns via JSL?

Here is the way I would handle your table.  It moves all of the USL and LSL values into the column property for each of the columns, and then the limits are automatically displayed when you graph the columns

txnelson_0-1698064958871.png

Names Default To Here( 1 );
dt = Current Data Table();

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

For Each( {col}, colNamesList,
	LSL = Column( col )[(dt << get rows where( :Label == "LSL" ))[1]];
	USL = Column( col )[(dt << get rows where( :Label == "USL" ))[1]];
	Eval(
		Substitute(
				Expr(
					Column( col ) << set property(
						"spec limits",
						{LSL( _LSL_ ), USL( _USL_ ), Show Limits( 1 )}
					)
				),
			Expr( _USL_ ), USL,
			Expr( _LSL_ ), LSL
		)
	);

);

// Uncomment the below 2 lines to delete the LSL and USL rows in the table
//dt << select where(:Label == "LSL" | :Label=="LSL");
//dt << delete rows;

Graph Builder(
	Size( 570, 578 ),
	Variables( X( :partID ), Y( :Current ), Y( :Resistance ) ),
	Elements( Position( 1, 1 ), Points( X, Y, Legend( 8 ), Jitter( "None" ) ) ),
	Elements( Position( 1, 2 ), Points( X, Y, Legend( 6 ), Jitter( "None" ) ) ),
	Local Data Filter( Add Filter( columns( :Label ), Where( :Label == {"Median"} ) ) )
);

 

Jim
Neo
Neo
Level VI

Re: How to get limits from from column and use it for other columns via JSL?

@txnelson @jthi 

Thanks, I will try your solution now. I wanted to do something similar but cannot get the following function to work. The idea is to apply this to a column group after grouping all the tested parameter columns. I tried it for one tested parameter (Current) column but it did not work. Works fine when numbers are passed for limits but not when variables are passed. Where did I go wrong (I have tried w & w/o Eval() and Expr()).

Names Default To Here( 1 );

setSpecLimits = Function( {dt_ref, colName, _LSL, _USL},
	{specLimits}, 

	tmp = Eval( Expr( dt_ref:colName << Set Property( "Spec Limits", {LSL( _LSL ), USL( _USL ), Show Limits( 1 )} ) ) );
	Return( specLimits ); //optional
);

////Check
Clear Log();
//test before
specLims = Data Table( "exampleData" ):Current << Get Property( "Spec Limits" ); Show( specLims ); 

//New values
_LSL = Data Table( "exampleData" ):Current[2]; Show( _LSL );
_USL = Data Table( "exampleData" ):Current[3]; Show( _USL );
dt_ref = Data Table( "exampleData" ); show (dt_ref);
colName = "Current"; Show( colName );

//call function
setSpecLimits( dt_ref, colName, _LSL, _USL ); 

//test after
specLims = Data Table( "exampleData" ):Current << Get Property( "Spec Limits" ); Show( specLims ); 

When it's too good to be true, it's neither
hogi
Level XII

Re: How to get limits from from column and use it for other columns via JSL?

Instead of Substitute, you can also use Eval (Eval Expr( ...Exp())):

Eval(EvalExpr(dt_ref:colName << Set Property( "Spec Limits", {LSL(Expr(_LSL )), USL(Expr( _USL) ), Show Limits( 1 )} )))

To pre-evaluate the spec limits _LSL & _USL they have to be inside Expr () and get pre-evaluated via Eval Expr().

After doing so, one can evaluate the whole expression via Eval()

txnelson
Super User

Re: How to get limits from from column and use it for other columns via JSL?

This should fix the problem

setSpecLimits = Function( {dt_ref, colName, _LSL, _USL},
	{specLimits}, 

	tmp = Eval(
		eval Expr(
			dt_ref:colName << Set Property( "Spec Limits", {LSL( expr(_LSL) ), USL( expr(_USL ) ), Show Limits( 1 )} )
		)
	);
	Return( specLimits ); //optional
);
Jim
Neo
Neo
Level VI

Re: How to get limits from from column and use it for other columns via JSL?

@txnelson Thanks. Eval Expr () does the trick.

How do I change the spec reference lines to dashed and change dashed line color to say red?

When it's too good to be true, it's neither
hogi
Level XII

Re: How to get limits from from column and use it for other columns via JSL?

You could use the GUI:

hogi_0-1698082106405.png

 

hogi
Level XII

Re: How to get limits from from column and use it for other columns via JSL?

or JSL:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt:height << Set Property("Spec Limits",{LSL( 57 ), USL( 67 )});


gb = dt << Graph Builder( Variables( X( :height ), Y( :weight ), Overlay( :sex ) ), Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) ), ); specs=dt:height << Get Property("Spec Limits"); LSL=specs["LSL"]; USL=specs["USL"]; report(gb)[ScaleBox(1)] <<{ Add Ref Line( LSL, "Dashed", "Red", "LSL", 1 ), Add Ref Line( USL, "Dashed", "Red", "USL", 1 )}
Neo
Neo
Level VI

Re: How to get limits from from column and use it for other columns via JSL?

@hogi  Thanks. I was looking for the JSL way to change solid line to dashed line and default color when the spec limits are defined and saved into column properties and then plotted automatically by JMP (as in post 3 by @txnelson). 

When it's too good to be true, it's neither