BookmarkSubscribe
Choose Language Hide Translation Bar
RyMcQeN
Community Trekker

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

 

 

 

0 Kudos
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
5 REPLIES 5
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
Community Trekker

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)?
0 Kudos
RyMcQeN
Community Trekker

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

0 Kudos
Highlighted
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
0 Kudos
RyMcQeN
Community Trekker

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