0

I have a massive amount of data which I would like to calculate some simple statistics (sum, mean, max). The data is grouped in columns and what I would like to do is calculate these statistics for the data in groups of sixteen columns. It is possible to manually select the columns to process but given the massive amount of data (365 columns x 601552 rows), I'm very likely to make mistakes. What I've been trying to figure out is how to get Excel to displace the cells selected each time the calculation is done. I know this entails the use of offset function but I can't figure out how to make it work. Any pointers will be highly appreciated. Thanks!

EDIT: Essentially the data looks as follows:

LAT   LONG       1      2      3       4    …    365
-40  -20     10.50   0.00   1.70    0.00    …   0.00
-40  -19.9   19.00   5.00   0.00    0.00    …   9.30
-40  -19.8    0.00   0.00   0.00    5.60    …   0.00
-40  -19.7   12.00   3.40   0.00    0.00    …   0.00
  …      …       …      …      …       …    …      …
 40   55      0.00   0.00   7.60    7.00    …   0.00

It is basically 365 days worth of rainfall for a large group of coordinates. What I want to do is collate basic stats (sum, mean and maximum rainfall) for each coordinate in 16-day aggregates (which comes to 22 full 16 day aggregates plus one with 13 or 14 days depending on whether it is a leap year). The formula I'm using right now is =SUM(OFFSET(C2,,,1,16)) which works fine for the first column (reference cell C2) but I want to copy this across the entire sheet. I think there is a way to get it to increment the reference cell by 16 each time but I can't seem to figure that out.

4

1 回答 1

1

这是您可能追求的概念的证明。我已将其设置为以四天为周期计算统计数据,但您应该能够将其扩展到 16 天周期:

在此处输入图像描述

  • 我复制了“标签”(LAT/LONG 值)来复制索引。
  • 单元格 D17 中的公式是

    =IF(MOD(COLUMN()-2,4)=0,AVERAGE(OFFSET(D17,-15,-3,1,4)),
     IF(MOD(COLUMN()-2,4)=3,MEDIAN(OFFSET(D17,-15,-2,1,4)),
     IF(MOD(COLUMN()-2,4)=2,MAX(OFFSET(D17,-15,-1,1,4)),"")))
    

    其中条件仅根据您所在的列显示特定统计信息。语法从高度和宽度中OFFSET(<ref>,<rows>,<cols>,<height>,<width>)选择一个范围(<rows>, <cols>)。因此,对于单元格 D17,选择 C2 中左上角的 1x4 范围。<ref><height><width>OFFSET(D17,-15,-3,1,4)

  • 您可以使用相同的公式来获取列标签MAX, MEDIAN, AVG, ...
于 2013-08-09T04:42:31.107 回答