How does one get the average of the last N rows in a table?

橙三吉。 提交于 2020-01-24 18:51:30

问题


I have a table (the "Table"). Table does not start on the first row of the spreadsheet (there are blanks rows above Table). There are no blank items in Table. Table contains OtherColumn, by which it is sorted, and Column.

OtherColumn    Column
a1             b1
a2             b2
...            ...
aN             bN

I want to find the average of the last N items in Column.

My current strategy involves =AVERAGE(OFFSET(M, -10, 0), M) where M is a cell reference to the last item in Column. How do I find M?

Prefer a non-VBA solution. Looking for a more elegant solution for M than:

CELL("address", OFFSET(Leaders[[#Headers],[Column]], COUNTA(B13:B1048576)-1, 0)) 

where C13 is the header row of the Table and C1048576 is the last row in Column B in the spreadsheet.


回答1:


Try this one:

=AVERAGE(INDEX(Table1[Column],ROWS(Table1[Column])-17):INDEX(Table1[Column],ROWS(Table1[Column])))

formula above gets average of last 18 elements in column Column.

Or using OtherColumn:

=AVERAGEIFS(Table1[Column],Table1[OtherColumn],">="&LARGE(Table1[OtherColumn],18))


来源:https://stackoverflow.com/questions/22830176/how-does-one-get-the-average-of-the-last-n-rows-in-a-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!