Here is the part of the script :
// Get the column names from the split data table, which are really the different release results
cols = dtsplitcopy << get column names( string );
// Loop across the split data table and read the values for that column from the dt_limits_copy data table. Populate the Spec Limits and Control Limits
For( i = 1, i <= N Cols( dtsplitcopy ), i++,
limrow = Try( (pIDlimits_copy << get rows where( pIDlimits_copy:labelny == cols[i] ))[1], . );
If( Is Missing( limRow ) == 0,
specs = {LSL( . ), USL( . ), Target( . ), Show Limits( 1 )};
specs["LSL"] = pIDlimits_copy:Lower Limit Value[limrow];
specs["USL"] = pIDlimits_copy:Upper Limit value[limrow];
Column( dtsplitcopy, Char( cols[i] ) ) << set property( "spec limits", Eval( specs ) );
controllimits = {Individual Measurement( Avg( a ), LCL( b ), UCL( c ) )};
// If lower limit is missing it is set to mean - (UCL - mean) = 2*mean - UCL as this will fix issues with zones otherwise being wrong if set to missing
Substitute Into( controllimits, Expr( b ), if(ismissing(pIDlimits_copy:Lower_Control_Limit[limrow]), 2*pIDlimits_copy:Mean_Plot[limrow] - pIDlimits_copy:Upper_Control_Limit[limrow], pIDlimits_copy:Lower_Control_Limit[limrow])); // this is done to get correct zones
Substitute Into( controllimits, Expr( c ), pIDlimits_copy:Upper_Control_Limit[limrow] );
Substitute Into( controllimits, Expr( a ), pIDlimits_copy:Mean_Plot[limrow] );
Column( dtsplitcopy, Char( cols[i] ) ) << set property( "control limits", Eval( controllimits ) );
// These notes are added so that later we can choose to hide the "artificial lower limits" which is only included for the zones to be correct
Column( dtsplitcopy, char( cols[i] ) ) << set property( "notes", if(ismissing(pIDlimits_copy:Lower_Control_Limit[limrow]),"Only one limit","Two limits"));
);
);
dtsplitcopy << sort( by( Date ), Replace Table );
n_vars = N Items(cols);
// Create window for a control chart for all parameters of a given product from a given site
NW = New Window(sitename || " " || prod_ID || " Report",
For( v = 39, v <= n_vars, v += 1, //changed from column 38 to 39 to avoid 'Date' being printet as well.
tmp = :column(v) << get property("notes");
Control Chart Builder(
Show Two Shewhart Charts( 0 ),
Show Control Panel( 0 ),
Include Missing Categories( 0 ),
Name( "AIAG (Ppk) Labeling" )(1),
Variables( Y( :Column(v)) ),
Chart(
Points( Statistic( "Individual" ) ),
Limits( Show Lower Limit( tmp == "Two limits" ), Sigma( "Moving Range" ), Zones( 1 ) ),
Warnings( Test 1( 0 ), Test 5( 1 ), Test Beyond Limits( 1 ) )
),
)
);
vlb = V List Box( ob = Outline Box("Cpk estimates and print of data") )
);