获取Google电子表格中最后X行的范围 [英] Get the range of the last X rows in Google Spreadsheet
问题描述
<$ p $
= AVERAGE(D12:D18)
我该怎么做同样没有硬编码他们,所以它会工作,因为我添加更多的行?
如果你想计算平均总之,不需要脚本。你也可以用一个数组过滤器来完成。以下公式计算A列中最后7行的平均值:
=平均值(过滤器(A:A; ARRAYFORMULA (ROW(A:A)> COUNT(A:A)-7 + 1)))
这假设数据从第1行开始。否则,你必须将公式中的后一个常量改为数据开始的行号。
Say I have a spresheet with 18 rows, and I can hard code the range of the last 7 values in column D and average their values like so:
=AVERAGE(D12:D18)
How then could I do the same without hard coding them, so it'll work as I add more rows?
If you want to calculate the average or sum, there's no need for a script. You can accomplish this with an array filter as well. The following formula calculates the average over the last 7 rows in the A column:
=AVERAGE(FILTER(A:A;ARRAYFORMULA(ROW(A:A)>COUNT(A:A)-7+1)))
This assumes that the data starts at row 1. Otherwise you have to change the latter constant in the formula to the row number where the data starts.
这篇关于获取Google电子表格中最后X行的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!