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
JesperJohansen
Level IV

Calculate moving average for By-Groups

I'm trying to calculate a moving average for a data-set containing several rounds of the continuous data. That is, I want a calculated average for every data-point, including the first and last. The average should be 7 steps in either direction, except for either end, where non-existing data beyond the 7 step window should simply ignored. Of course I don't want data form different By-Groups to be included in the same average. I was hoping to use the "Col Mean" function, but I can't figure out how to make the average "move". Any suggestions?

BR
Jesper
1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: Calculate moving average for By-Groups

Hi Jesper,

You can use the Summation function with an If() condition to do this.

Here's a picture of what it would look like in the formula editor.

3927_JMPScreenSnapz002.png

And here's the text version:

Summation(

  i = Row() - 7,

  Row() + 7,

  If( :DAY == :DAY

  :DIAMETER,

  .

  )

) / Summation( i = Row() - 7, Row() + 7, If( :DAY == :DAY, 1, . ) )

Hope that helps.

-Jeff

-Jeff

View solution in original post

4 REPLIES 4
keith
Level I

Re: Calculate moving average for By-Groups

Do you have ETS licenced?  If so, there is functionality within PROC EXPAND to calculate moving averages

JesperJohansen
Level IV

Re: Calculate moving average for By-Groups

I do have access to EST, but I have never used it. I was hoping to do it directly in the formula editor.

BR
Jesper
Jeff_Perkinson
Community Manager Community Manager

Re: Calculate moving average for By-Groups

Hi Jesper,

You can use the Summation function with an If() condition to do this.

Here's a picture of what it would look like in the formula editor.

3927_JMPScreenSnapz002.png

And here's the text version:

Summation(

  i = Row() - 7,

  Row() + 7,

  If( :DAY == :DAY

  :DIAMETER,

  .

  )

) / Summation( i = Row() - 7, Row() + 7, If( :DAY == :DAY, 1, . ) )

Hope that helps.

-Jeff

-Jeff
JesperJohansen
Level IV

Re: Calculate moving average for By-Groups

That was exactly what I needed. Great! Thank you.

BR
Jesper

Recommended Articles