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
RyMcQeN
Level III

How to use JSL to Get Limits in IR Control Chart

Hello,

 

Assuming I have a limits table saved with multiple parameter columns like shown below. Is there a way to read in this file and apply the limits to an IR chart for the matching parameters using JSL?

 

Capture.PNG

 

 

According to the following post there is no way to invoke the "Get Limits" function from the Control Chart dialog using JSL. In this case it was suggested to hard code the limits. 

How-to-Get-Limits-for-Capability-on-IR-Control-Chart

 

I am thinking I need to read the limits file in, capture the Sigma, Avg, LCL, and UCL as variables then pass them to the Chart Col for each parameter.  If this is the only way to do it, what would be the most efficient way to approach it?

 

See below example of the code for a single control chart parameter with phase level and limits hard coded:

 

Control Chart(
	Sample Label( :WEEK ),
	Phase( :YEAR ),
	Group Size( 1 ),
	KSigma( 3 ),
	Chart Col(
		:P1,
		Individual Measurement(
			Test 1( 1 ),
			Test 2( 1 ),
			Test 5( 1 ),
			Test 6( 1 ),
			Phase Level(
				"2019",
				Sigma( 0.0106958422036977 ),
				Avg( 5.59766666666667 ),
				LCL( 5.56557914005557 ),
				UCL( 5.62975419327776 )
			)
		)
	)
);

 

Thank you in advance.

 

Ry

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to use JSL to Get Limits in IR Control Chart

There are 2 basic ways to do this.

  1. Read the data from the limits table, and then save the limits as Column Properties. Then run the charts desired.
  2. Loop across the columns to be charted, reading in the limits from the limits table and inserting them into the JSL to generate the charts.

It is the second of these methods I have used for the script below.  It should be a working script, but without actually having your limits table, and the actual data table, it is possible there may be some glitches.

Names Default To Here( 1 );
dt = Open( "path to data table" );
dtLimits = Open( "path to limits table" );

// Get list of columns to chart
colNameList = dt << get column names( continuous, string );

// Loop across all of the columns and create the charts
For( i = 1, i <= N Items( colNameList ), i++, 

	// If limits exist for the current column, then process
	If( Try( Column( dtLimits, colNameList[i] ) << get name ) != "", 

		// get the limits needed
		// sigma

		theSigma = Column( dtLimits, colNameList[i] )[(dtLimits <<
		get rows where( _LimitsKey == "_Std Dev" ))[1]];
		theAvg = Column( dtLimits, colNameList[i] )[(dtLimits <<
		get rows where( _LimitsKey == "_Mean" ))[1]];
		theLCL = Column( dtLimits, colNameList[i] )[(dtLimits <<
		get rows where( _LimitsKey == "_LCL" ))[1]];
		theUCL = Column( dtLimits, colNameList[i] )[(dtLimits <<
		get rows where( _LimitsKey == "_UCL" ))[1]];

		Eval(
			Substitute(
					Expr(
						Control Chart(
							Sample Label( :WEEK ),
							Phase( :YEAR ),
							Group Size( 1 ),
							KSigma( 3 ),
							Chart Col(
								__process__,
								Individual Measurement(
									Test 1( 1 ),
									Test 2( 1 ),
									Test 5( 1 ),
									Test 6( 1 ),
									Phase Level(
										"2019",
										Sigma( __sigma__ ),
										Avg( __avg__ ),
										LCL( __LCL__ ),
										UCL( __UCL__ )
									)
								)
							)
						)
					),
				Expr( __process__ ), Parse( ":" || colNameList[i] ),
				Expr( __sigma__ ), theSigma,
				Expr( __avg__ ), theAvg,
				Expr( __LCL__ ), theLCL,
				Expr( __UCL__ ), theUCL
			)
		);
	)
);
Jim

View solution in original post

10 REPLIES 10
txnelson
Super User

Re: How to use JSL to Get Limits in IR Control Chart

There are 2 basic ways to do this.

  1. Read the data from the limits table, and then save the limits as Column Properties. Then run the charts desired.
  2. Loop across the columns to be charted, reading in the limits from the limits table and inserting them into the JSL to generate the charts.

It is the second of these methods I have used for the script below.  It should be a working script, but without actually having your limits table, and the actual data table, it is possible there may be some glitches.

Names Default To Here( 1 );
dt = Open( "path to data table" );
dtLimits = Open( "path to limits table" );

// Get list of columns to chart
colNameList = dt << get column names( continuous, string );

// Loop across all of the columns and create the charts
For( i = 1, i <= N Items( colNameList ), i++, 

	// If limits exist for the current column, then process
	If( Try( Column( dtLimits, colNameList[i] ) << get name ) != "", 

		// get the limits needed
		// sigma

		theSigma = Column( dtLimits, colNameList[i] )[(dtLimits <<
		get rows where( _LimitsKey == "_Std Dev" ))[1]];
		theAvg = Column( dtLimits, colNameList[i] )[(dtLimits <<
		get rows where( _LimitsKey == "_Mean" ))[1]];
		theLCL = Column( dtLimits, colNameList[i] )[(dtLimits <<
		get rows where( _LimitsKey == "_LCL" ))[1]];
		theUCL = Column( dtLimits, colNameList[i] )[(dtLimits <<
		get rows where( _LimitsKey == "_UCL" ))[1]];

		Eval(
			Substitute(
					Expr(
						Control Chart(
							Sample Label( :WEEK ),
							Phase( :YEAR ),
							Group Size( 1 ),
							KSigma( 3 ),
							Chart Col(
								__process__,
								Individual Measurement(
									Test 1( 1 ),
									Test 2( 1 ),
									Test 5( 1 ),
									Test 6( 1 ),
									Phase Level(
										"2019",
										Sigma( __sigma__ ),
										Avg( __avg__ ),
										LCL( __LCL__ ),
										UCL( __UCL__ )
									)
								)
							)
						)
					),
				Expr( __process__ ), Parse( ":" || colNameList[i] ),
				Expr( __sigma__ ), theSigma,
				Expr( __avg__ ), theAvg,
				Expr( __LCL__ ), theLCL,
				Expr( __UCL__ ), theUCL
			)
		);
	)
);
Jim
RyMcQeN
Level III

Re: How to use JSL to Get Limits in IR Control Chart

Thank you Jim. I had to make a small edit to the Get Rows Where( _LimitsKey == ...) sections. Just added the colon ":" so it becomes Get Rows Where( :_LimitsKey == ...) then everything worked. One question though. The script is generating individual windows for each parameter control chart. Is there a way to generate one window with the control charts of each parameter stacked (as if I selected multiple parameters in the IR Control chart dialog)?
RyMcQeN
Level III

Re: How to use JSL to Get Limits in IR Control Chart

Hi Jim,

 

Can you show me how to approach the first method you mentioned? Reading in the limits from the limits table then applying them as column properties.

 

Thank you,

 

Ry

txnelson
Super User

Re: How to use JSL to Get Limits in IR Control Chart

If you interactively set the Control Limits for an IR chart and then use the following JSL to retrieve the limits,

:columnname <<get property("control limits");

The structure that is stored for the Column Property will be shown

{Individual Measurement(
	Avg( 62.55 ),
	LCL( 51.574420384821 ),
	UCL( 73.525579615179 )
)}

So all that has to be done, is to read the info from your limits data table, and then build the above structure and pass it to the measurement data table column.  Below is a modification of my previous script, except that it populates the Control Limits, rather than running the control charts

Names Default To Here( 1 );
dt = Open( "path to data table" );
dtLimits = Open( "path to limits table" );

// Get list of columns to chart
colNameList = dt << get column names( continuous, string );

// Loop across all of the columns and create the charts
For( i = 1, i <= N Items( colNameList ), i++, 

	// If limits exist for the current column, then process
	If( Try( Column( dtLimits, colNameList[i] ) << get name ) != "", 

		// get the limits needed
		
		theAvg = Column( dtLimits, colNameList[i] )[(dtLimits << get rows where( _LimitsKey == "_Mean" ))[1]];
		theLCL = Column( dtLimits, colNameList[i] )[(dtLimits << get rows where( _LimitsKey == "_LCL" ))[1]];
		theUCL = Column( dtLimits, colNameList[i] )[(dtLimits << get rows where( _LimitsKey == "_UCL" ))[1]];

		Eval(
			Substitute(
				Expr(
					__Process__ << set property(
						"Control Limits",
						{Individual Measurement( Avg( __avg__ ), LCL( __LCL__ ), UCL( __UCL__ ) )}
					)
				),
				Expr( __process__ ), Parse( ":" || colNameList[i] ),
				Expr( __avg__ ), theAvg,
				Expr( __LCL__ ), theLCL,
				Expr( __UCL__ ), theUCL
			)
		);
	)
);
Jim
RyMcQeN
Level III

Re: How to use JSL to Get Limits in IR Control Chart

Thank you for the fast reply Jim.  I was trying to set the Control Limits and the Sigma property and was getting an error for:

too many arguments in access or evaluation of 'Expr' , Expr/*###*/(Column( finalDt, colNamesList[i] ) <<
Set Property(
	"Control Limits",
	{Individual Measurement( Avg( __avg__ ), LCL( __LCL__ ), UCL( __UCL__ ) )}
), Column( finalDt, colNamesList[i] ) << Set Property( "Sigma", __sigma__ ))

The problem was that I was trying to define two different column properties in the same substitute expression.  After breaking it up into 2 Evals, it works.  See below.

 

	Current Data Table( finalDt );
	Wait(0);

	// Get list of columns to chart
	colNameList = finalDt << get column names( continuous, string );

	// Loop across all of the columns and create the charts
	For( i = 2, i <= N Items( colNameList ), i++, 

		// If limits exist for the current column, then process
		If( Try( Column( dtLimits, colNameList[i] ) << get name ) != "", 

			// get the limits needed
			// sigma

			theSigma = Column( dtLimits, colNameList[i] )[(dtLimits << get rows where( :_LimitsKey == "_Std Dev" ))[1]];
			theAvg = Column( dtLimits, colNameList[i] )[(dtLimits << get rows where( :_LimitsKey == "_Mean" ))[1]];
			theLCL = Column( dtLimits, colNameList[i] )[(dtLimits << get rows where( :_LimitsKey == "_LCL" ))[1]];
			theUCL = Column( dtLimits, colNameList[i] )[(dtLimits << get rows where( :_LimitsKey == "_UCL" ))[1]];

			Eval(
				Substitute(
					Expr( __process__ << Set Property("Control Limits", {Individual Measurement( Avg( __avg__ ), LCL( __LCL__ ), UCL( __UCL__ ))})),
					Expr( __process__ ), Parse( ":" || colNameList[i] ),
					Expr( __avg__ ), theAvg,
					Expr( __LCL__ ), theLCL,
					Expr( __UCL__ ), theUCL
				)
			);
			Eval(
				Substitute(
					Expr( __process__ << Set Property("Sigma", __sigma__)),
					Expr( __process__ ), Parse( ":" || colNameList[i] ),
					Expr( __sigma__ ), theSigma,
				)
			);
		)
	);

Thanks again for your quick help.

 

Ry

AlexS
Level III

Re: How to use JSL to Get Limits in IR Control Chart

Hello I have come across this solution and tried to implement it but it’s not working for me it opens the files I specify at the top of the script but doesn’t continue on with the rest of the script. It might be something to do with the Phase part but I don’t completely understand where it comes from? Thank you for your help
Alex is the name, Power BI/ SQL /JMP is my game
txnelson
Super User

Re: How to use JSL to Get Limits in IR Control Chart

What error messages are you getting in the log?
Jim
AlexS
Level III

Re: How to use JSL to Get Limits in IR Control Chart

 

Not Found in access or evaluation of 'Control Chart' , Bad Argument( {:Month Alerted, :YEAR} ), Control Chart(/*###*/Sample Label( :Month Alerted ),
	Phase( :YEAR ),
	Group Size( 1 ),
	KSigma( 3 ),
	Chart Col(
		:Grand Total,
		Individual Measurement(
			Test 1( 1 ),
			Test 2( 1 ),
			Test 5( 1 ),
			Test 6( 1 ),
			Phase Level(
				"2019",
				Sigma( 9843.52246062887 ),
				Avg( 54802.5935983333 ),
				LCL( 25272.0262164467 ),
				UCL( 84333.1609802199 )
			)
		)
	)
)

 

 

My columns are Month Alerted the column data content is 12 months in this format 2019-04 so I changed the sample label to :Month Alerted.

the next part is the YEAR and Phase which doesn't match my data so i think that's where it doesn't work?

 

The limits are multiple columns but each with a different header ideally i don't want to write every column header.

i also need the size (500,175) but unsure where this fits in the code and save to the data table.

 

I did try using the Control chart builder but i couldn't get the limits to be added. I select the file but it did nothing after it. Which meant i couldn't get some sort of script.

 

Many thanks - I have attached the script

Alex is the name, Power BI/ SQL /JMP is my game

Re: How to use JSL to Get Limits in IR Control Chart

You can use JSL with the Get Limits command for an IR Control Chart.  The post you referenced was about Specification Limits and not Control Limits.  If you have control limits, you can use the following JSL with the Get Limits command.

dt = Open("$SAMPLE_DATA/Quality Control/Coating.jmp");
obj = Control Chart(
	Sample Size( Column(dt, "Sample") ),
	Chart Col( :Weight, XBar, R ),
	Get Limits(
		"$SAMPLE_DATA/Quality Control/CoatingLimits.jmp"
	)
);