Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- How do I compute a 24 hour rolling average

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 3, 2020 1:26 PM
(839 views)

I need to compute a 24 hour rolling average for each individual subject.

I have the following columns:

Subject ID

Time stamp

Milk yeild

Can anyone help direct me in the right direction?

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Here is a simple script that creates your rolling average. It creates a new column and uses a formula to generate the rolling average. Attached is a sample data table with the new column. Please validate the calculations

```
Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Rolling Average",format("Percent",7,2),
Formula(
curTime = :Time stamp;
curSubject = :Subject ID;
Mean(
:Milk yield[dt <<
get rows where(
:time stamp >= curTime - In Days( 1 ) & :time stamp
<= curTime & curSubject == Subject ID
)]
);
)
);
```

Jim

2 REPLIES 2

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Here is a simple script that creates your rolling average. It creates a new column and uses a formula to generate the rolling average. Attached is a sample data table with the new column. Please validate the calculations

```
Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Rolling Average",format("Percent",7,2),
Formula(
curTime = :Time stamp;
curSubject = :Subject ID;
Mean(
:Milk yield[dt <<
get rows where(
:time stamp >= curTime - In Days( 1 ) & :time stamp
<= curTime & curSubject == Subject ID
)]
);
)
);
```

Jim

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How do I compute a 24 hour rolling average

This worked great! Just what I was looking for. Thank you

Article Labels

There are no labels assigned to this post.