Script for Control Charts (all numeric Columns) with saved Limits in one tableHi,
I'm trying to generate one Window/Report with several Control Charts (all numeric columns of the data table). So far I was able to generate this report. But I'm not able to save all Limits in one data table. Can anybody help me?
Following my code
dt = Current Data Table ();
//Deselection von allen Spalten
cols = dt << get column names();
For(i = 1, i <= N Col(dt), i++,
cols[i] << set selected (0)
);
//Selection
cc = dt << Get Column Names( numeric );
ncols = N Items( cc );
For( i = 1, i <= ncols, i++,
cc[i] << Set Selected( 1 )
);
nw1 = New Window ("Control Charts");
For( i = 1, i <= ncols, i++,
test = cc[i];
conc = Control Chart(
Group Size( 1 ),
KSigma( 3 ),
Chart Col(as Column (test) ),
Chart Type( Moving Range )
); nw1 << append (Report(conc)); conc << Close Window);
nw1 << in New Table;Re: Script for Control Charts (all numeric Columns) with saved Limits in one table. . . and here's an alternative using column properties:
NamesDefaultToHere(1);
// Make a table with some random data
dt = NewTable("Charts");
n = 5;
dt << addMultipleColumns("C_", n, Numeric);
dt << addRows(20);
for(c=1, c<=n, c++, Column(dt, "C_"||Char(c)) << formula(RandomNormal(0, 1)));
dt << runFormulas;
// Put the charts into a single window
nw1 = New Window ("Control Charts",
For( c = 1, c <= n, c++,
thisCC = dt << Control Chart(
Group Size( 1 ),
KSigma( 3 ),
Chart Col(Column(dt, "C_"||Char(c))),
Chart Type( Moving Range )
);
// Save the computed limits as a column property
thisCC << inColumn;
);
);
// Make a blank limits table
dt2 = NewTable("Limts",
NewColumn("Column", Character),
NewColumn("Avg", Numeric),
NewColumn("LCL", Numeric),
NewColumn("UCL", Numeric),
<< addRows(n)
);
// Populate the limits table by parsing the saved column property
For( c = 1, c <= n, c++,
clExpr = Column(dt, "C_"||Char(c)) << getProperty("Control Limits");
Column(dt2, "Column")[c] = "C_"||Char(c);
Column(dt2, "Avg")[c] = Arg(Arg(Arg(clExpr, 1), 1), 1);
Column(dt2, "LCL")[c] = Arg(Arg(Arg(clExpr, 1), 2), 1);
Column(dt2, "UCL")[c] = Arg(Arg(Arg(clExpr, 1), 3), 1);
);
I suspect this might be simpler with Control Chart Builder, but I didn't check (and you may have reasons for using the 'old' platform anyway).
Re: Script for Control Charts (all numeric Columns) with saved Limits in one tableThank you very much. It works perfectly. It will save so much time 
Re: Script for Control Charts (all numeric Columns) with saved Limits in one tableHere is my solution to your code. I commented out code that I did not see was serving any purpose for this specific issue
Names Default To Here( 1 );
dt = Current Data Table();
//Deselection von allen Spalten
/*cols = dt << get column names();
For( i = 1, i <= N Col( dt ), i++,
cols[i] << set selected( 0 )
);*/
//Selection
cc = dt << Get Column Names( numeric );
/*ncols = N Items( cc );
For( i = 1, i <= ncols, i++,
cc[i] << Set Selected( 1 )
);*/
nw1 = New Window( "Control Charts" );
For( i = 1, i <= N Items( cc ), i++,
Current Data Table( dt ); // Should not be required, but script would not work without it
conc = dt << Control Chart( Group Size( 1 ), KSigma( 3 ), Chart Col( As Column( cc[i] ) ), Chart Type( Moving Range ) );
concDT = conc << in New Table;
concDT << New Column( "Column", character, set each value( Char( cc[i] ) ) );
Column( concDT, Char( cc[i] ) ) << set name( "Value" );
If( i == 1,
baseDT = concDT,
baseDT << concatenate( concDT, append to first table( 1 ) );
Close( concDT, nosave );
);
nw1 << append( Report( conc ) );
conc << Close Window;
);