cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Security Notice: CVE-2026-109618 and CVE-2026-109619

    JMP promptly initiated a review of its products, services, and relevant infrastructure for exposure to CVE-2026-109618 and CVE-2026-109619.

    Our assessment of JMP products has not identified exposure to these vulnerabilities. Where remediation was required within supporting environments, appropriate security updates and controls have been applied and validated.

    We have identified no evidence of successful exploitation or unauthorized access to JMP systems or customer information associated with these vulnerabilities.

    JMP continues to monitor the issue and relevant vendor guidance. No action is required by JMP customers at this time.

  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Jackie_
Level VII

Loop to find max value for each unique values

Hi,

 

I am trying to iterate over each values of X and Y and save the max rn value in the MaxValue column. 

 

Here is what I tried but something doesn't seem correct. Any advice?

Names Default To Here( 1 );

dt = Current Data Table();

dt << begin data table();

// Loop through rows
For( i = 1, i <= N Rows( dt ), i++,
	currentBarcode = dt:Barcode[i];
   // Find the location of the maximum rn value for the current Barcode
	maxRNRow = Max( dt:rn[dt:Barcode[i] == currentBarcode] );
   // Check if the maxRNRow is not 0 (meaning there is at least one matching Barcode)
	If( maxRNRow != 0, 
       // Update "MaxValue" column with the max rn value for the current Barcode
		dt:MaxValue[i] = dt:rn[maxRNRow]
	);
);
dt << end data table();

Jackie__0-1702402546406.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
mmarchandTSI
Level V

Re: Loop to find max value for each unique values

Try this instead.

 

Col Max( :rn, :Y, :X )

 

edit

 

To be clearer, set the formula for :MaxValue to

 

Col Max( :rn, :Barcode )

 

View solution in original post

5 REPLIES 5
mmarchandTSI
Level V

Re: Loop to find max value for each unique values

Try this instead.

 

Col Max( :rn, :Y, :X )

 

edit

 

To be clearer, set the formula for :MaxValue to

 

Col Max( :rn, :Barcode )

 

Jackie_
Level VII

Re: Loop to find max value for each unique values

@mmarchandTSI Col max works only with :Barcode column. The issue is some table don't have Barcode column so am trying to see if I can use X and Y Coordinates to assign the max rn value in

jthi
Super User

Re: Loop to find max value for each unique values

You can add more than one byvar

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column("Maximum Value for Each Age and Sex Group",
	Formula(Col Maximum(:height, :age, :sex))
);

jthi_0-1702578708979.png

Col Max() 

-Jarmo
mmarchandTSI
Level V

Re: Loop to find max value for each unique values

Right, so the first formula I posted will work for what you're doing, as @jthi alluded to.

jthi
Super User

Re: Loop to find max value for each unique values

No loops needed here. You can do what @mmarchandTSI suggested and use Col Max with byvar, you could use Summarize to calculate the maximum values and then create new column using those or you could create summary table and join (or rather update) that to your table with the max value. Also the the begin/end messages are

dt << Begin Data Update;
dt << End Data Update;
-Jarmo

Recommended Articles