Photo by Constantin on Unsplash |How To Coda A Moving Average

How To Coda A Moving Average

Based on a question in the community

In my blog post How to Coda Rolling Total I suggested to make use of the FormulaMap()

Below the solution I proposed and a bit further the same with an extra element: a controller to select the days you want.

Moving Average

Again it is based on the FormulaMap() to first get the all the dates in step 01

This is a good start, but we need only the last 7 days and to get this we use the Slice() function with a negative number:

Instead of writing 7 in the function, I created a controller to have a more flexible approach:

using a controller to play with the numbers

Note that I first make sure the number is always positive — via AbsolutValue() and next I make it negative.

The outcome is a date range and this one I’ll use in my Filter(). First I apply a WithName() to keep the function understandable and off we go

a flexible solution for a moving average

I turn the Text Column into a Number column, put the decimals on 2 and add the IfBlank(“”) at the end.

finishing touch using IfBlank()

This solution works also when the values you deal with are not dates due to the RowIndex formula. In case you deal only with dates, Joostmineur showed me an even easier way (many thx Joost!):

solution provided by Joost using a filter

You find the table you see above over here :

I hope you enjoyed this article. If you have questions feel free to reach out. Though this article is for free, my work (including advice) won’t be, but there is always room for a chat to see what can be done. Besides you find my (for free) contributions to the Coda Community and on Twitter

My name is Christiaan Huizer and I am the owner of Huizer Automation. A company specialized in serving SME in harvesting data and keeping it aligned. I am a Coda Consultant & Expert and rely mainly on Coda, Mailjet, Zapier & Paperform to get the job done.

Huizer Automation — Coda Expert and Consultant on “How To Coda A Moving Average”



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store