简体   繁体   English

平均值的平均值Excel公式

[英]Average of averages Excel formula

how do I make a single formula that will take the n-week average of m-week averages? 如何制作一个将n周平均值和m周平均值相乘的公式?

Suppose I have data in A2:A21 , and in D21 , I want the 8 week average of 4-week moving averages up to A21. 假设我在A2:A21有数据,并且在D21 ,我希望4周移动平均值的8周平均值达到A21。 So my idea would be 所以我的想法是

{=AVERAGE(AVERAGE(OFFSET(A21,-4+1-ROW(OFFSET(A1,0,0,8))+1,0,4)))}

So for example, with this data: 因此,例如,使用以下数据:

data    4 wk aver   8 wk avg avg
79      
79      
66      
38  66  
34  54  
13  38  
22  27  
50  30  
40  31  
98  53  
81  67  46
27  62  45
64  68  47
12  46  48
83  47  50
94  63  54
4   48  57
41  56  57
4   36  53
6   14  47

I am looking for a formula to calculate 47... My formula above calculates 57.8. 我正在寻找一个公式来计算47 ...我上面的公式计算得出57.8。

Answer is to use SUBTOTAL() on the inner average instead. 答案是在内部平均值上使用SUBTOTAL() This will return a column of averages, so the outer AVERAGE() will have the correct behavior. 这将返回一列平均值,因此外部AVERAGE()将具有正确的行为。

{=AVERAGE(SUBTOTAL(1,OFFSET(A21,-4+1-ROW(OFFSET(A1,0,0,8))+1,0,4)))}

The reason the original solution didn't work is because the inner AVERAGE was just taking the total average of all the arrays, instead of returning a column of their individual averages. 原始解决方案不起作用的原因是,内部AVERAGE只是获取所有数组的总平均值,而不是返回其各自平均值的一列。 I find this SUBTOTAL() trick useful when you need to do this kind of thing. 当您需要执行此类操作时,我发现此SUBTOTAL()技巧很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM