There are many way to tackle the moving average. I don't see any issues with the "TAKE" version, however, I tend to avoid OFFSET if it is practical due to its volatility. That may be more of a theoretical reason than a practical one, as I suspect your worksheet performance will not suffer noticeably (and I don't know what the performance penalty might be with LAMBDAs). Another option is to form the range to be taken dynamically using a different method (other than OFSET). But the most significant difference that would lead me to favor the LAMBDA is that the results spill from a single formula---no copying down the column...only one formula to enter/maintain. Also, the nature of the LAMBDA is that it's "code" is rather generic, making it easier to port to other applications. In this case, a copy of Jon's formula from the web site can be pasted directly into the worksheet, and then the two arguments (datarange and numpoints) are passed into it for the results.
The formula is somewhat more complicated, but some of that complexity is due to the syntax and behavior of LAMBDA functions. Once the formula is dissected, the individual components are fairly clear. For example, you'll find TAKE in there, in the calculation that forms the dynamic range of data to be used...for the variable named
movingdatarange:
Excel Formula:
DROP(TAKE(datarange,r),MAX(0,r-numpoints))
Here we are taking the top r rows of the datarange, meaning that if we are on the 7th row index (where you have a value of 2 in the example), TAKE(datarange,r) creates the array {3;6;1;7;3;1;2}. Then notice this array is passed to the DROP function where we drop (eliminate) MAX(0,r-numpoints) elements of the array. So
r is the row index (7) and
numpoints is an input variable whose value is 5. So this expression becomes MAX(0,2), which means we'll drop the top 2 elements of the array, leaving {1;7;3;1;2} for the 5-element average in the next step...AVERAGE(movingdatarange). When
r<=
numpoints, the MAX expression results in 0, so no elements of the range would be dropped, which is what happens at the top of the data range before we've moved down
n points.