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
Lindeman1arr
Level II

Set limit to columns without overriding other limit

I'm needing to put limits into a data column from a separate table.  That table has a "0" if that particular limit is not set.  This script works fine for loading the limits if there are no limits, or if it has both limits, but I have been unable to get it to work when there is just one limit.  It puts both in leaving the second limit set at "0".

//set limits
		If( db_Tests:MinLimit[TestRow[1]] != 0 | db_Tests:MaxLimit[TestRow[1]] != 0, 

			Eval(
				Substitute(
						Expr(
							col << set property( "Spec Limits", {LSL( _L ), USL( _U ), Show Limits( 1 )} )
						),
					Expr( _L ), db_Tests:MinLimit[TestRow[1]]
					,
					Expr( _U ), db_Tests:MaxLimit[TestRow[1]]
				)
			)
		);

I tried putting them in one at a time. If the LSL is not "0" update the LSL, then if USL is not "0" update that one.  The problem with that is it overwrites the first one if they both have limits.  In other words, that way works for every case except when both LSL and USL exist, but when they both exist it puts the first one in and then when it puts the second one in the first one is gone.  I'd appreciate any help on this one. Thanks 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Set limit to columns without overriding other limit

How about setting the 0 values to missing with something like this:

Names Default To Here(1);

dt = New Table("Untitled 2",
	Add Rows(2),
	Compress File When Saved(1),
	New Column("col", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2]))
);

//both
minVal = 1;
maxVal = 2;
Eval(
	Substitute(
		Expr(
			dT:col << set property( "Spec Limits", {LSL( _L ), USL( _U ), Show Limits( 1 )} )
			),
		Expr( _L ), If(minVal == 0, ., minVal)
		,
		Expr( _U ), If(maxVal == 0, ., maxVal)
	)
);

Show(dt:col << Get Property("Spec Limits"));

//missing maxval
minVal = 1;
maxVal = .;
Eval(
	Substitute(
		Expr(
			dT:col << set property( "Spec Limits", {LSL( _L ), USL( _U ), Show Limits( 1 )} )
			),
		Expr( _L ), If(minVal == 0, ., minVal)
		,
		Expr( _U ), If(maxVal == 0, ., maxVal)
	)
);

Show(dt:col << Get Property("Spec Limits"));

//maxval 0
minVal = 1;
maxVal = 0;
Eval(
	Substitute(
		Expr(
			dT:col << set property( "Spec Limits", {LSL( _L ), USL( _U ), Show Limits( 1 )} )
			),
		Expr( _L ), If(minVal == 0, ., minVal)
		,
		Expr( _U ), If(maxVal == 0, ., maxVal)
	)
);

Show(dt:col << Get Property("Spec Limits"));

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Set limit to columns without overriding other limit

How about setting the 0 values to missing with something like this:

Names Default To Here(1);

dt = New Table("Untitled 2",
	Add Rows(2),
	Compress File When Saved(1),
	New Column("col", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2]))
);

//both
minVal = 1;
maxVal = 2;
Eval(
	Substitute(
		Expr(
			dT:col << set property( "Spec Limits", {LSL( _L ), USL( _U ), Show Limits( 1 )} )
			),
		Expr( _L ), If(minVal == 0, ., minVal)
		,
		Expr( _U ), If(maxVal == 0, ., maxVal)
	)
);

Show(dt:col << Get Property("Spec Limits"));

//missing maxval
minVal = 1;
maxVal = .;
Eval(
	Substitute(
		Expr(
			dT:col << set property( "Spec Limits", {LSL( _L ), USL( _U ), Show Limits( 1 )} )
			),
		Expr( _L ), If(minVal == 0, ., minVal)
		,
		Expr( _U ), If(maxVal == 0, ., maxVal)
	)
);

Show(dt:col << Get Property("Spec Limits"));

//maxval 0
minVal = 1;
maxVal = 0;
Eval(
	Substitute(
		Expr(
			dT:col << set property( "Spec Limits", {LSL( _L ), USL( _U ), Show Limits( 1 )} )
			),
		Expr( _L ), If(minVal == 0, ., minVal)
		,
		Expr( _U ), If(maxVal == 0, ., maxVal)
	)
);

Show(dt:col << Get Property("Spec Limits"));

 

-Jarmo
Lindeman1arr
Level II

Re: Set limit to columns without overriding other limit

Thanks, that worked great!