cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
%3CLINGO-SUB%20id%3D%22lingo-sub-87647%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87647%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E6%9C%89%E4%B8%80%E4%B8%AA%E5%90%8D%E4%B8%BA%20drugs%20%E7%9A%84%E8%A1%A8%EF%BC%8C%E5%85%B6%E4%B8%AD%E5%8C%85%E5%90%AB%20drug%20%E5%92%8C%20result%20%E5%88%97%EF%BC%8C%E5%A6%82%E4%BD%95%E8%AE%A1%E7%AE%97%E7%BB%93%E6%9E%9C%E5%88%97%E7%9A%84%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E5%80%BC%EF%BC%8C%E6%96%B9%E6%B3%95%E6%98%AF%E5%85%88%E5%8F%96%E5%89%8D%204%20%E8%A1%8C%EF%BC%8C%E7%84%B6%E5%90%8E%E5%86%8D%E5%8F%96%E4%B8%8B%204%20%E8%A1%8C%EF%BC%8C%E7%84%B6%E5%90%8E%E7%B1%BB%E4%BC%BC%E5%9C%B0%E7%BB%A7%E7%BB%AD%E3%80%82%20Pfa%20%E7%A4%BA%E4%BE%8B%E8%A1%A8%E4%BE%9B%E5%8F%82%E8%80%83%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-532174%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-532174%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJMP%20%E7%9A%84%E6%94%AF%E6%8C%81%E6%96%87%E6%A1%A3%E4%B8%BA%E5%A6%82%E4%BD%95%E5%AE%9A%E4%B9%89%E5%85%AC%E5%BC%8F%E6%8F%90%E4%BE%9B%E4%BA%86%E4%B8%80%E4%BA%9B%E9%A2%9D%E5%A4%96%E7%9A%84%E8%83%8C%E6%99%AF%E4%BF%A1%E6%81%AF%EF%BC%88%E5%AE%9A%E4%B9%89%E4%BA%86%E5%8F%82%E6%95%B0%EF%BC%8C%E8%BF%98%E5%8C%85%E6%8B%AC%E4%B8%80%E4%BA%9B%E4%B8%8D%E9%94%99%E7%9A%84%E5%B0%8F%E7%A4%BA%E4%BE%8B%EF%BC%89%EF%BC%9A%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F16.2%2F%23page%2Fjmp%2Fstatistical-functions-2.shtml%23%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F16.2%2F%23page%2Fjmp%2Fstatistical-functions-2.shtml%23%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22PatrickGiuliano_0-1660093800183.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22PatrickGiuliano_0-1660093800183.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22PatrickGiuliano_0-1660093800183.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F44691i32DEE1055F339075%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22PatrickGiuliano_0-1660093800183.png%22%20alt%3D%22PatrickGiuliano_0-1660093800183.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E4%BD%A0%E5%8F%AF%E4%BB%A5%E5%9C%A8%E7%BB%B4%E5%9F%BA%E7%99%BE%E7%A7%91%E4%B8%AD%E6%89%BE%E5%88%B0%EF%BC%88%3CA%20href%3D%22https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FMoving_average%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FMoving_average)%3C%2FA%3E%E6%9B%B4%E5%A4%9A%E5%85%B3%E4%BA%8E%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E8%AE%A1%E7%AE%97%E8%83%8C%E5%90%8E%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86%E5%92%8C%E6%95%B0%E5%AD%A6%2F%E6%A6%82%E5%BF%B5%E7%90%86%E8%A7%A3%EF%BC%9A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-105084%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-105084%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E8%B0%A2%E8%B0%A2%E8%BF%99%E6%9C%89%E6%95%88%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-105083%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-105083%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3Eweighting%20%3D%201%2C%20before%20%3D%203%2C%20%3ADrug%20%E6%98%AF%E4%BB%80%E4%B9%88%E6%84%8F%E6%80%9D%EF%BC%9F%3CBR%20%2F%3E%E4%BD%A0%E8%83%BD%E8%A7%A3%E9%87%8A%E4%B8%80%E4%B8%8B%E5%85%AC%E5%BC%8F%E5%90%97%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-105082%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-105082%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E8%BF%99%E6%B2%A1%E6%9C%89%E7%94%A8%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-88024%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-88024%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Moving%20average%20dialog.png%22%20style%3D%22width%3A%20373px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Moving%20average%20dialog.png%22%20style%3D%22width%3A%20373px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Moving%20average%20dialog.png%22%20style%3D%22width%3A%20373px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F15002i2532FCBB9DB58BDE%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Moving%20average%20dialog.png%22%20alt%3D%22Moving%20average%20dialog.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%E6%88%91%E8%AE%A4%E4%B8%BA%E8%BF%99%E5%B0%86%E4%B8%BA%E6%82%A8%E6%8F%90%E4%BE%9B%E6%89%80%E9%9C%80%E7%9A%84%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%EF%BC%88%E5%89%8D%204%20%E8%A1%8C%E5%92%8C%E5%90%8E%204%20%E8%A1%8C%EF%BC%89%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87746%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87746%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E4%BD%BF%E7%94%A8%E7%9A%84%E5%85%AC%E5%BC%8F%E6%98%AF%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EIf(%20Mod(%20Row()%2C%204%20)%20%3D%3D%200%2C%0A%20Mean(%20%3AResult%5BIndex(%20Row()%20-%203%2C%20Row()%20)%5D%20)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%E6%88%91%E9%99%84%E4%B8%8A%E4%BA%86%E6%82%A8%E7%9A%84%E7%A4%BA%E4%BE%8B%E6%95%B0%E6%8D%AE%E8%A1%A8%EF%BC%8C%E5%85%B6%E4%B8%AD%E5%8C%85%E5%90%AB%E4%B8%80%E4%B8%AA%E5%8C%85%E5%90%AB%E5%85%AC%E5%BC%8F%E7%9A%84%E6%96%B0%E5%88%97%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22drugs.PNG%22%20style%3D%22width%3A%20512px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22drugs.PNG%22%20style%3D%22width%3A%20512px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22drugs.PNG%22%20style%3D%22width%3A%20512px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F15001i63F40F710CA32DDB%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22drugs.PNG%22%20alt%3D%22drugs.PNG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87744%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87744%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E6%83%B3%E7%94%9F%E6%88%90%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E5%88%97%EF%BC%8C%E5%A6%82%E9%99%84%E8%A1%A8%E6%89%80%E7%A4%BA%EF%BC%8C%E6%AF%8F%204%20%E8%A1%8C%E6%88%91%E9%9C%80%E8%A6%81%E8%AE%A1%E7%AE%97%E5%B9%B3%E5%9D%87%E5%80%BC%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87743%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87743%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E6%82%A8%E6%98%AF%E5%90%A6%E6%9C%89%204%20%E5%88%97%E7%BB%93%E6%9E%9C%EF%BC%8C%E6%88%96%E8%80%85%E6%98%AF%E7%A4%BA%E4%BE%8B%E6%95%B0%E6%8D%AE%E8%A1%A8%E4%B8%AD%E6%98%BE%E7%A4%BA%E7%9A%84%E8%A1%8C%E6%95%B0%E7%9A%84%204%20%E5%80%8D%EF%BC%9F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87741%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87741%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E4%BD%A0%E8%83%BD%E8%A7%A3%E9%87%8A%E4%B8%80%E4%B8%8B%E8%BF%99%E4%B9%8B%E5%90%8E%E7%9A%84%E4%B8%8B%E4%B8%80%E6%AD%A5%E5%90%97%EF%BC%8C%E6%88%91%E6%83%B3%E8%AE%A1%E7%AE%97%204%20%E4%B8%AA%E8%BF%9E%E7%BB%AD%E6%A0%B7%E6%9C%AC%E7%9A%84%E5%B9%B3%E5%9D%87%E5%80%BC%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87662%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87662%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%9C%A8%E6%95%B0%E6%8D%AE%E8%A1%A8%E4%B8%AD%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%96%B0%E5%88%97%EF%BC%8C%E5%B9%B6%E5%BA%94%E7%94%A8%E4%BB%A5%E4%B8%8B%E5%85%AC%E5%BC%8F%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ECol%20Moving%20Average(%20%3AResult%2C%20weighting%20%3D%201%2C%20before%20%3D%203%2C%20%3ADrug%20)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87661%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87661%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%20%EF%BC%8C%3C%2FP%3E%3CP%3E%E6%82%A8%E5%8F%AF%E4%BB%A5%E5%B0%9D%E8%AF%95%E4%BD%BF%E7%94%A8%E5%85%AC%E5%BC%8F%E5%88%97%20--%26gt%3B%20%E8%A1%8C%20--%26gt%3B%20%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E7%BA%BF%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22moving.jpg%22%20style%3D%22width%3A%20908px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22moving.jpg%22%20style%3D%22width%3A%20908px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22moving.jpg%22%20style%3D%22width%3A%20908px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F14982i470944843464D147%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22moving.jpg%22%20alt%3D%22moving.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
jojmp
Level III

Moving Average

I have a table called drugs with columns drug and result, how do I calculate the moving average of the result column by taking the first 4 rows followed by the next 4 rows and similarly continue. Pfa the sample table for reference. 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Moving Average

The formula to use is

If( Mod( Row(), 4 ) == 0,
	Mean( :Result[Index( Row() - 3, Row() )] )
)

I have attached your example data table, with a new column with the formula in it

drugs.PNG

Jim

View solution in original post

11 REPLIES 11
gianpaolo
Level IV

Re: Moving Average

hello ,

you can try with Formula column --> row --> moving average

 

moving.jpg

Gianpaolo Polsinelli
jojmp
Level III

Re: Moving Average

Could you please explain the next step after this, I want to calculate the average of 4 consecutive samples
txnelson
Super User

Re: Moving Average

Do you have 4 columns of results, or 4 times as many rows as you show in your sample data table?
Jim
jojmp
Level III

Re: Moving Average

I want to generate the moving average column as shown in the attached table, for every 4 rows I need to calculate the average

txnelson
Super User

Re: Moving Average

The formula to use is

If( Mod( Row(), 4 ) == 0,
	Mean( :Result[Index( Row() - 3, Row() )] )
)

I have attached your example data table, with a new column with the formula in it

drugs.PNG

Jim
jojmp
Level III

Re: Moving Average

Thanks this worked
Phil_Kay
Staff

Re: Moving Average

Moving average dialog.png

I think this will give you the moving average that you want (4 rows before and 4 rows after).

jojmp
Level III

Re: Moving Average

this did not work
txnelson
Super User

Re: Moving Average

Create a new column in your data table, and apply the folloing formula

Col Moving Average( :Result, weighting = 1, before = 3, :Drug )
Jim