获取Google电子表格中最后X行的范围 [英] Get the range of the last X rows in Google Spreadsheet

查看:92
本文介绍了获取Google电子表格中最后X行的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个18行的spresheet,并且我可以硬编码D列中最后7个值的范围,并将它们的值平均为这样:

<$ 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆