I have a table below stating the defects per week per manufacturing site. How do I write a JMP script to output another table stating just the top 3 defects per week per site? I am using JMP17.
| Defects | Date | Site1 | Site2 |
| Bondpad | 2023_WK4 | 166 | |
| Bump_Deformities | 2023_WK4 | 2868 | 1085 |
| Contamination | 2023_WK4 | 75121 | 22763 |
| Crack | 2023_WK4 | 5726 | |
| Discoloration | 2023_WK4 | 1762 | |
| Distorted_Break | 2023_WK4 | 56 | |
| Lifting | 2023_WK4 | 6717 | |
| Missing_Bump | 2023_WK4 | 565 | |
| Missing_Die | 2023_WK4 | 639 | |
| Other | 2023_WK4 | 2855 | |
| Scratch | 2023_WK4 | 98115 | 79122 |
| Test_Failure | 2023_WK4 | 192 | |
| Twin | 2023_WK4 | 2704 | 11841 |
| Bondpad | 2023_WK5 | 178 | |
| Bump_Deformities | 2023_WK5 | 716 | 192 |
| Contamination | 2023_WK5 | 37999 | 43074 |
| Crack | 2023_WK5 | 4110 | 2452 |
| Discoloration | 2023_WK5 | 3326 | |
| Lifting | 2023_WK5 | 12145 | |
| Missing_Bump | 2023_WK5 | 352 | |
| Missing_Die | 2023_WK5 | 984 | |
| Other | 2023_WK5 | 8878 | |
| Scratch | 2023_WK5 | 71792 | 32075 |
| Streaking | 2023_WK5 | 5 | |
| Test_Failure | 2023_WK5 | 359 | |
| Twin | 2023_WK5 | 9011 | 10987 |
Here is a little script that produces the below output
Names Default To Here( 1 );
dt = Current Data Table();
dtStack = dt << Stack(
columns( :Site1, :Site2 ),
Source Label Column( "Site" ),
Stacked Data Column( "Defect Count" ),
Output Table( "Stacked" )
);
dtStack << Sort(
By( :Date, :Site, :Defect Count ),
Order( Ascending, Ascending, Descending ),
Replace Table( 1 )
);
// New column: Column 5
dtStack << New Column( "Rank",
Numeric,
"Continuous",
Format( "Best", 12 ),
formula( Col Cumulative Sum( 1, :Date, :Site ) )
);
dtStack:Rank << delete formula;
dtStack << Select Where( :Rank > 3 );
dtStack << delete rows;
Here is a little script that produces the below output
Names Default To Here( 1 );
dt = Current Data Table();
dtStack = dt << Stack(
columns( :Site1, :Site2 ),
Source Label Column( "Site" ),
Stacked Data Column( "Defect Count" ),
Output Table( "Stacked" )
);
dtStack << Sort(
By( :Date, :Site, :Defect Count ),
Order( Ascending, Ascending, Descending ),
Replace Table( 1 )
);
// New column: Column 5
dtStack << New Column( "Rank",
Numeric,
"Continuous",
Format( "Best", 12 ),
formula( Col Cumulative Sum( 1, :Date, :Site ) )
);
dtStack:Rank << delete formula;
dtStack << Select Where( :Rank > 3 );
dtStack << delete rows;
Jim, it works beautifully! Thanks!