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