I'm trying to average the last 6 cells in a column. This data will be added to and I need it to update automatically as the data is added to.
I tried =AVERAGE(TAKE(FILTER(C5:C528,C5:C528<>0), ,-6))
Result was the average of the whole table 149.6
I also tried =INDEX(AVERAGE(ARRAY_CONSTRAIN(SORT(FLATTEN(INDIRECT("A6:"&ADDRESS(1,MAX(ISNUMBER(C:C)*ROW(C:C))))),SEQUENCE(MAX(ISNUMBER(C:C)*ROW(C:C))), 0), 6, 1)))
Result is "You have entered too few arguments for this function."
Both were copied from this websites and the references were updated for my worksheet. I was trying to get the value 143 which is the average of the last 6 values in the example.
Something simple:
=AVERAGE(OFFSET(A1,COUNTA(A:A)-6,0,6,1))
Something easy to read for Excel 365:
=LET(
lastRow, COUNTA(A:A),
startRow, lastRow - 5,
AVERAGE(INDEX(A:A, startRow):INDEX(A:A, lastRow))
)
Something unnecessary difficult to confuse your friends and enemies:
=LET(
lastRow, COUNTA(A:A),
startRow, lastRow - 5,
range, INDEX(A:A, startRow):INDEX(A:A, lastRow),
rangeArray, SEQUENCE(ROWS(range), 1, startRow, 1),
AVERAGE(INDEX(A:A, rangeArray))
)