It's not as simple as just using AVERAGE actually. I've had the exact problem with Google Sheets. I wanted to create a trailing average of last 7 of the numerical values in another column. I had to Google quite a bit to figure out how to handle it so the 1st to 6th row would work out well. Right now I described the issue to ChatGPT, and it was very quickly able to suggest me the following for Excel:
=IF(ROW(A1)=1, A1, IF(ROW(A1)=2, AVERAGE(A1:A2), AVERAGE(OFFSET(A1,-2,0,3,1))))
For Google Sheets and trailing 7 it suggested me following:
=IF(ROW(A2) < 8, AVERAGE(A$2:A2), AVERAGE(OFFSET(A2,-6,0,7,1)))
If you know everything by heart, it may seem simple, but it's not just using one function, it's using multiple and knowing the exact parameters, intricacies.
With Google Sheets, it would've faster for me to just use the JavaScript with Apps Script, to create this, rather than trying to figure out the syntax of this.
So it uses 4 different functions there,
1. IF
2. ROW
3. AVERAGE
4. OFFSET
And in such a way that I would just not come to think of it on my own out of the blue. I would try several different approaches before I were to try this one. Although it's really easy to just write a script for that.
And maybe you also want to be able to dynamically configure the trailing average size, which this formula allows for very easily. Compared to when you Google, some of the articles suggest just using AVERAGE(A2:A8), but it's missing those other frequent requirements.
And when you look at some Stack Overflow answers the formulas are even crazier:
https://stackoverflow.com/questions/40779177/how-to-average-...
=round(AVERAGE(OFFSET(H1,MAX(ARRAYFORMULA(ROW(H:H)--(H:H<>"")))-7,,7)))
https://stackoverflow.com/questions/70282014/find-rolling-av...
=INDEX(AVERAGE(ARRAY_CONSTRAIN(SORT(INDIRECT("A1:"&
ADDRESS(MAX(ISNUMBER(A:A)ROW(A:A)), 1, )),
SEQUENCE(MAX(ISNUMBER(A:A)*ROW(A:A))), 0), 7, 1)))