Rolling Averages - Where to begin?

Hi everyone,

I have a really tricky requirement (or I’m over thinking it) that I need some help getting started.

I have a table in Airtable that lists the last 12 months and a value associated with it

I need to create a rolling value next to it. This value is derived from adding the previous rows together and dividing them by the number of rows.

Example: Rolling Number for Nov-22 is 0.69 (Oct-22 Number Value + Nov-22 Number Value / 2)

How would I approach this? anyone point me in the right direction please?

Hi Jason,

It is more a Airtable question.
I found two references that may help you:

Hope this will help.

Philippe

2 Likes

Thanks for responding Philippe,

Its very cumbersome in Airtable and The data I’m pulling from is across multiple bases so I was hoping there was a way in Make as that’s what I’m using to collate the data.

I managed to find a sufficient answer for this in the FB group. It’s an Airtable solution but thought it might be useful:


// change these names to pick a view:
let table = base.getTable('Table 11');
let view = table.getView('Grid view');
let result = await view.selectRecordsAsync({ fields: ['Number'] });
let runningTotal = 0;
let count = 0; // Initialize a counter for the number of records
for (let record of result.records) {
// change the field names here to adapt this script to your base
runningTotal += record.getCellValue('Number');
count++; // Increment the counter for each record
let runningAverage = runningTotal / count; // Calculate the running average
await table.updateRecordAsync(record, {
'Rolling Average': runningAverage, // Update this field with the running average
});
}
1 Like

Heya @currently.jason :wave:

Wow! I am impressed by the fact you were able to crack this with the assistance of @Philippe_Billet .
Thanks a lot for keeping the community in mind and coming back here with additional information and solution.

Great job and keep it up!

1 Like