cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • 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.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

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

JSL- Formula for calculating column average for last x rows per ID

I am trying to create a column formula to calculate the average for the last 30 sets of data per cycle run (shown in the example below):

AvgLlama27_0-1727273049807.png

I have been able to achieve this, however I would like to be able to calculate the average per "ID" rather than the entire data set per test cycle.

 

The formula I have used is shown below:

If( Row() == Col Max( Row(), :Cycle ),
	Mean( As Column( "Output, mV" )[Index( Row() - 29, Col Max( Row(), :Cycle ) )] )
)

...but I am unsure of where to go next. 

 

Thanks in advance.

 

1 REPLY 1
jthi
Super User

Re: JSL- Formula for calculating column average for last x rows per ID

Have you checked out if Col Moving Average could do what you are looking for?

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt << new column("avg", Numeric, Continuous, Formula(
	If(Row() == Col Max(Row(), :sex),
		Col Moving Average(:height, 1, 9, 0, 1, :sex);
	);
));
-Jarmo

Recommended Articles