cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
rmthomas
Level III

How to create a data table subgroup for a control chart using a subset button function

Hello Everyone,

 

I am trying to create a data table subgroup for a control chart using a subset button function. I found this link Creating a Subset from an Interactive Graph?  to something similar but it is for rows. I would like to use the Columns instead. I have multiple columns and I am using the column switcher with the control charts. I would like to be able to select specific data points on the control chart and only get the data for those points in that specific column. 

 

Below is the JSL I tried to use and I tried to modify to columns and failed. 

dt5= Data Table( "SPC Columns" );
colNamesList = dt5 << get Column names (string, Continuous);

gb= dt5 << Control Chart Builder(
	Size( 534, 464 ),
	Show Control Panel( 0 ),
	Variables( Y( eval(colNamesList[1]) ) ),
	Chart(
		Position( 1 ),
		Limits( Shade Zones( 1 ) ),
		Warnings(
			Test 1( 1 ),
			Test 2( 1 ),
			Test 3( 1 ),
			Test 4( 1 ),
			Test 5( 1 ),
			Test 6( 1 ),
			Test 7( 1 ),
			Test 8( 1 )
		)),
Column Switcher(colNamesList[1], Eval( colNamesList ))
	
);

subsetButton = Button Box( "Click to Create a Subset of Selected Points",
	If( N Rows( dt5 << get selected rows ) > 0,
		dt5 << subset( selected rows( 1 ), selected columns( 0 ) )
	)
);

Report( gb )["Graph Builder"] << append( subsetButton );

 

This will give me all the columns that have data in the rows I would just like the single column of data when I select those specific data points. 

 

Thank you for your help,

 

-Ryan

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp
Staff

Re: How to create a data table subgroup for a control chart using a subset button function

You've done most of the work. Here's one way to finish it off:

NamesDefaultToHere(1);

// Data table with some continuous columns
dt = Open("$SAMPLE_DATA/Big Class.jmp" );
colNamesList = dt << get Column names (string, Continuous);

// Control chart
gb = dt << Control Chart Builder(Show Control Panel( 0 ), Variables( Y( eval(colNamesList[1]) ) ));

// Add a column switcher
cs = gb << Column Switcher(colNamesList[1], Eval( colNamesList ));

// 'Extra' button with subset action
subsetButton = Button Box("Click to Create a Subset of Selected Points",
							If( N Rows( dt << get selected rows ) > 0,
								currentCol = cs << getCurrent;
								dt2 = dt << subset( selected rows( 1 ), Columns(Eval(Column(dt, currentCol))));
								dt2 << setName("Subset of "||(dt << getName)||" using "||currentCol);
								,
								Beep();
								);
							);

// Add this button to the control chart report (use 'topParent' so that this is not affected by any column switcher changes)
(Report(gb)[OutlineBox("Control Chart Builder")] << topParent) << append(subsetButton);

View solution in original post

1 REPLY 1
ian_jmp
Staff

Re: How to create a data table subgroup for a control chart using a subset button function

You've done most of the work. Here's one way to finish it off:

NamesDefaultToHere(1);

// Data table with some continuous columns
dt = Open("$SAMPLE_DATA/Big Class.jmp" );
colNamesList = dt << get Column names (string, Continuous);

// Control chart
gb = dt << Control Chart Builder(Show Control Panel( 0 ), Variables( Y( eval(colNamesList[1]) ) ));

// Add a column switcher
cs = gb << Column Switcher(colNamesList[1], Eval( colNamesList ));

// 'Extra' button with subset action
subsetButton = Button Box("Click to Create a Subset of Selected Points",
							If( N Rows( dt << get selected rows ) > 0,
								currentCol = cs << getCurrent;
								dt2 = dt << subset( selected rows( 1 ), Columns(Eval(Column(dt, currentCol))));
								dt2 << setName("Subset of "||(dt << getName)||" using "||currentCol);
								,
								Beep();
								);
							);

// Add this button to the control chart report (use 'topParent' so that this is not affected by any column switcher changes)
(Report(gb)[OutlineBox("Control Chart Builder")] << topParent) << append(subsetButton);