Choose Language Hide Translation Bar
Highlighted
Level II

## Keep or toss a part on one bad measurement

I have a data set of  45 parts with 50 measurements across the surface of the part. If even one measurement is below the minimum I want to discard the part. I've made a column with an if/then that returns either "Too Thin" or "Good" but that is for each discrete measurement. I want a list that is just "Keep" or "Recycle" by part (lab time is restricted due to the pandemic, so I want to be efficient). I feel like I'm close but not close enough! A script answer would be helpful.

4 REPLIES 4
Highlighted
Level VI

## Re: Keep or toss a part on one bad measurement

Hi,
A simple trick I use is to code the single measure Pass / Fail as 1 and 0 (similarly to out you have done) and then add a new column where you calculate the Column Minimum of Pass / Fail by Part (Col Minimum(:Pass-Fail, :Part)). This will return 1 only for the parts where all measurements were set a 1, and will return 0 for any part where at least 1 measurement failed.
Best,

Thierry
Thierry R. Sornasse
Highlighted
Level II

## Re: Keep or toss a part on one bad measurement

Ah! The "by part" was the part that I think I was missing. Thank you very much for that bit.

Highlighted
Level II

## Re: Keep or toss a part on one bad measurement

Okay, the "by part" was definitely something I was missing, so now I have this

``````If( Col Minimum( If( :Name( "Measurement" ) <= 5000, 0, 1 ), :Part ),
"Recycle",
"Keep"
)``````

and it is returning the correct label, but I'm still stuck on to how to make a list from that. I can make a table that shows the part and the number of Keep vs Recycles each part has (50 of course). That'll work well enough for going down to lab, but I was still sort of hoping for a straight list.

Highlighted
Super User

## Re: Keep or toss a part on one bad measurement

Here is an example you can use to get to your final answer.  It is pretty straight forward on how it works.  I have annotated the code in hopes to help with the understanding.  All of the functions used are documented in the Scripting Index.  The use of matrices and Lists are documented in the Scripting Guide.  Only the last 15 lines or so are the part in the code that calculates the Recycle/Keep component.

``````Names Default To Here( 1 );

// Create some sample data.  The Semiconductor Capability data table
// has a lot of numerical columns, and they have spec limits assigned
// to the columns.  So I am selecting a data table with 10 of the columns,
// and am using the Lower Spec Limit as the value to determine if a
// measurement is either Good, or Too Thin
dt = Open( "\$SAMPLE_DATA/semiconductor capability.jmp" );
dt << delete columns( 1 :: 4 );
dt << delete columns( 11 :: N Cols( dt ) );

// Find the number of columns
nc = N Cols( dt );

// Create the Good/Too Thin columns
For( i = 1, i <= nc, i++,
specs = Column( dt, i ) << get property( "spec limits" );
dt << New Column( (Column( dt, i ) << get name) || " Good or Too Thin", character );

selRows = dt << get rows where( As Column( dt, i ) > specs["LSL"] );
If( N Rows( selRows ) > 0,
Column( dt, nc + i )[selRows] = "Good"
);
selRows = dt << get rows where( As Column( dt, nc + i ) == "" );
If( N Rows( selRows ) > 0,
Column( dt, nc + i )[selRows] = "Too Thin"
);
);

// Create the overall column
dt << New Column( "Keep Recycle", character );

// Set the start and end of which columns to look for the Too Thin value in
end = nc + nc;
start = nc + 1;

// Loop across all rows checking for Too Thin and setting the Recycle or Keep value
For( i = 1, i <= N Rows( dt ), i++,
// Use the ability to directly reference the cells in a data table
// to use a Contains() function to find if any entries for the
// current row have Too Thin as it's value
If( Contains( dt[i, start :: end], "Too Thin" ),
dt:Keep Recycle[i] = "Recycle",
dt:Keep Recycle[i] = "Keep"
)
);``````
Jim
Article Labels