Calculating a running/moving average in Excel is obvious. A non-moving (stationary?) average is both harder to implement and trickier to search for!
Specifically, I want to calculate a column of data which is the average of contiguous sets of x
values from another column, so I can visualise the effects of x
when compared to the raw data.
The formula I've come up with works, but seems unnecessarily complex:
=AVERAGE(INDIRECT(ADDRESS(1+ROW()-MOD(ROW(),$D$1),1)):INDIRECT(ADDRESS($D$1+ROW()-MOD(ROW(),$D$1),1)))
It uses INDIRECT and ADDRESS to programmatically calculate a cell range that extends from the current row, up to and down to the current set of x
rows. x
is specified in D1. Without all the guff, it's just AVERAGE(ii%x:i+xi%x), but it looks a lot uglier than that.
Sample data:
Raw Averaged 10
2428 2426.3
2425 2426.3
2421 2426.3
2423 2426.3
2432 2426.3
2431 2426.3
2421 2426.3
2431 2426.3
2427 2426.3
2424 2426
2426 2426
2431 2426
2429 2426
2428 2426
2428 2426
2424 2426
2425 2426
2422 2426
2420 2426
2427 2425.5
2427 2425.5
2421 2425.5
2425 2425.5
Avenues for a solution that were unsuccessfully explored were decimation type questions and specifying cells by row and column as numbers type questions.
这有点干净,但是依赖于预定义的数据向量:
={AVERAGE(IF(ROUNDDOWN((ROW(A$2:A$24)-2)/$D$1,0)=ROUNDDOWN((ROW(A2)-2)/$D$1,0),A$2:A$24))}
我能想到的最简单的公式是
=AVERAGE(OFFSET(A:A,(INT((ROW()-1)/$D$1)*$D$1+1),0,$D$1,1))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.