Tweaked that to have a selectable Yield Threshold.
ex = New Window( "Enter % Pass Threshold",
<<modal,
Panel Box( "Tabulate Parameters Below Threshold",
H List Box( Text Box( "% Pass:" ), teb = Number Edit Box() )
),
teb << Set Width( 5 ),
Panel Box( "Options",
H List Box(
ok_button = Button Box( "OK", na = teb << get text ),
canc_button = Button Box( "Cancel" )
)
)
);
If( ex["Button"] == -1,
teb = Empty();
Throw();
);
colList = dt << get column names( numeric, string );
SpecCols = {};
PctPass = {};
For Each({colnames, index}, colList,
spec = Column(dt, colnames) << get property( "Spec Limits" );
If( !Is Empty( spec ), Insert Into (SpecCols, colnames)));
Failcols = {};
// Loop across the columns and generate the test pass/fails
For Each({colnames, index}, SpecCols,
spec = Column(dt, colnames) << get property( "Spec Limits" );
lsl = spec["LSL"]; // Lower Spec Limit
usl = spec["USL"]; // Upper Spec Limit
failCount = N Rows( dt << Get Rows Where((As Column(dt, colnames)[]<lsl) | (As Column(dt, colnames)[]>usl)));
passCount = N Rows( dt << Get Rows Where((As Column(dt, colnames)[]>lsl) & (As Column(dt, colnames)[]<usl)));
yield = 100 * passCount / (passCount + failCount);
if(yield < Num( na ),
Insert Into( Failcols, colnames );
if(yield < Num( na ),
Insert Into( PctPass, yield )
);
);
);
Show( Failcols );
New Table( "Prevalent Failures",
Add Rows( 0 ),
New Column( "Failing Parameters", Character, "Nominal", Set Values( Failcols ) ),
New Column( "% Passing",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( PctPass )
)
);
Slán
SpannerHead