I have a data set where I'd like to calculate the mean of the last 3 observations for each date and have that value be in its own column and paired with the last date as shown below.
Names Default To Here( 1 );
// Create an example data table
dt = New Table( "Date",
Add Rows( 30 ),
New Column( "Date",
Numeric,
"Continuous",
Format( "m/d/y", 10 ),
Set Values( [3713817600, 3713817600, 3713817600, 3713817600, 3713817600, 3713817600, 3713817600, 3713817600, 3713817600, 3713817600,
3715027200, 3715027200, 3715027200, 3715027200, 3715027200, 3715027200, 3715027200, 3715027200, 3715027200, 3715027200,
3716236800, 3716236800, 3716236800, 3716236800, 3716236800, 3716236800, 3716236800, 3716236800, 3716236800, 3716236800] )
),
New Column( "Data",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [2,4,6,8,10,12,14,16,18,20,2,4,6,8,10,12,14,26,28,30,2,4,6,8,10,12,14,36,38,40] )
),
New Column( "Desired Result",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [.,.,.,.,.,.,.,.,.,18,.,.,.,.,.,.,.,.,.,28,.,.,.,.,.,.,.,.,.,38] )
),
);
While I can create a summary table that calculates the mean and then insert the mean back in the original data table, I'm looking for a suggestion for a more elegant and less process intensive method. Any suggestions on how to accomplish this would be appreciated, either as a column formula, or via JSL (preferred).