While putting everything one would need to accomplish what you want into a column formula could be done, it is much simpler using a little script run in open code. Here is an example
names default to here(1);
dt =
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
// create a column to represent the original order of the data
dt << new column("Orig Row", set each value(row()));
// Find 5 lowest values of NPN1 for each site
dt << sort( by(:NPN1), order(descending), replace table(1));
dt << new column("minimum NPN1", set each value(
if(col cumulative sum(1,:site) <= 5, 1, 0)
));
// Set the table back to the original order
dt << sort( by(:Orig Row), order(ascending), replace table(1));
dt << delete columns(Orig Row);
Jim