cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-662314%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E9%80%9A%E8%BF%87Var%E8%AF%86%E5%88%AB%E6%9C%80%E4%BD%8E%E7%9A%845%E4%B8%AA%E8%BF%9E%E7%BB%AD%E8%A1%8C%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-662314%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%81%87%E8%AE%BE%E6%88%91%E6%9C%89%E4%B8%80%E4%B8%AA%20RunNumber%20(1%2C2%2C3...)%20%E5%92%8C%20Result%20%EF%BC%88%E6%95%B0%E5%AD%97%2F%E8%BF%9E%E7%BB%AD%EF%BC%89%E8%A1%A8%E3%80%82%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E5%A6%82%E4%BD%95%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E5%85%AC%E5%BC%8F%E5%88%97%E6%9D%A5%E6%A0%87%E8%AF%86%EF%BC%88%E4%BE%8B%E5%A6%82%E4%BD%BF%E7%94%A8%E2%80%9C1%E2%80%9D%EF%BC%89%E6%AF%8F%E4%B8%AA%20RunNumber%20%E5%85%B7%E6%9C%89%E6%9C%80%E4%BD%8E%E5%B9%B3%E5%9D%87%E5%80%BC%E7%9A%84%205%20%E4%B8%AA%E6%95%B0%E5%AD%97%E7%9A%84%E5%BA%8F%E5%88%97%EF%BC%8C%E8%80%8C%E5%85%B6%E4%BB%96%E5%9C%B0%E6%96%B9%E5%88%99%E6%A0%87%E8%AF%86%E4%B8%BA%E2%80%9C0%E2%80%9D%EF%BC%9F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-662314%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3E%E6%95%B0%E6%8D%AE%E6%B7%B7%E5%90%88%E5%92%8C%E6%B8%85%E7%90%86%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-662322%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E9%80%9A%E8%BF%87Var%E8%AF%86%E5%88%AB%E6%9C%80%E4%BD%8E%E7%9A%845%E4%B8%AA%E8%BF%9E%E7%BB%AD%E8%A1%8C%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-662322%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E8%99%BD%E7%84%B6%E5%8F%AF%E4%BB%A5%E5%B0%86%E5%AE%8C%E6%88%90%E6%89%80%E9%9C%80%E4%BB%BB%E5%8A%A1%E6%89%80%E9%9C%80%E7%9A%84%E6%89%80%E6%9C%89%E5%86%85%E5%AE%B9%E6%94%BE%E5%85%A5%E5%88%97%E5%85%AC%E5%BC%8F%E4%B8%AD%EF%BC%8C%E4%BD%86%E4%BD%BF%E7%94%A8%E5%9C%A8%E5%BC%80%E6%94%BE%E4%BB%A3%E7%A0%81%E4%B8%AD%E8%BF%90%E8%A1%8C%E7%9A%84%E5%B0%8F%E8%84%9A%E6%9C%AC%E8%A6%81%E7%AE%80%E5%8D%95%E5%BE%97%E5%A4%9A%E3%80%82%E8%BF%99%E6%98%AF%E4%B8%80%E4%B8%AA%E4%BE%8B%E5%AD%90%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Enames%20default%20to%20here(1)%3B%0Adt%20%3D%20%0A%2F%2F%20Open%20Data%20Table%3A%20semiconductor%20capability.jmp%0A%2F%2F%20%E2%86%92%20Data%20Table(%20%22semiconductor%20capability%22%20)%0AOpen(%20%22%24SAMPLE_DATA%2Fsemiconductor%20capability.jmp%22%20)%3B%0A%0A%2F%2F%20create%20a%20column%20to%20represent%20the%20original%20order%20of%20the%20data%0Adt%20%26lt%3B%26lt%3B%20new%20column(%22Orig%20Row%22%2C%20set%20each%20value(row()))%3B%0A%0A%2F%2F%20Find%205%20lowest%20values%20of%20NPN1%20for%20each%20site%0Adt%20%26lt%3B%26lt%3B%20sort(%20by(%3ANPN1)%2C%20order(descending)%2C%20replace%20table(1))%3B%0A%0Adt%20%26lt%3B%26lt%3B%20new%20column(%22minimum%20NPN1%22%2C%20set%20each%20value(%0A%20if(col%20cumulative%20sum(1%2C%3Asite)%20%26lt%3B%3D%205%2C%201%2C%200)%0A))%3B%0A%0A%2F%2F%20Set%20the%20table%20back%20to%20the%20original%20order%0Adt%20%26lt%3B%26lt%3B%20sort(%20by(%3AOrig%20Row)%2C%20order(ascending)%2C%20replace%20table(1))%3B%0Adt%20%26lt%3B%26lt%3B%20delete%20columns(Orig%20Row)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
BHarris
Level VII

Identify lowest 5 sequential rows byVar

Suppose I have a table of RunNumber (1,2,3...) and Result (numeric/continuous).

 

How can I create a formula column that identifies (e.g. with a "1") the sequence of 5 Result numbers with the lowest average value for each RunNumber, and a "0" everywhere else?

1 REPLY 1
txnelson
Super User

Re: Identify lowest 5 sequential rows byVar

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

Recommended Articles