我想计算最后一个移动平均线,即20个数字的列。一个问题是列的某些单元格可能是空的,它们应该被忽略。示例:
A 175 154 188 145 155 167 201A最后三次的移动平均线将为(155 + 167 + 201)/ 3。我试图使用平均值,偏移量,索引来实现这一点,但是我根本不知道如何。我有点熟悉宏,所以这样的解决方案可以正常工作: = MovingAverage(A1; 3)
感谢任何提示或解决方案!
解决方案{= SUM A $ 1:A9)*(ROW($ A $ 1:A9)>轻便((ROW($ A $ 1:A9))*(NOT(ISBLANK($ A $ 1:A9))),3 + 1))) / 3}
使用控件+ shift + enter输入以使其成为数组公式。这将找到最新的三个值。如果你想要更多或更少,请将公式中的两个实例更改为任何您想要的。
LARGE(( R $($ A $ 1:A9))*(NOT(ISBLANK($ A $ 1:A9))),3 + 1)此部分返回具有值的所有单元格的第4行行数,或者示例中为5,因为行6,8和9是具有值的第1到第3行。 ($ A $ 1:A9)> LARGE((R $($ A $ 1:A9))*(NOT(ISBLANK) ($ A $ 1:A9))),3 + 1))
此部分返回9个TRUE或根据行号是否大于第四大,FALSE。
($ A $ 1:A9)*(ROW($ A $ 1:A9)> LARGE((ROW($ A $ 1:A9))*(NOT(ISBLANK($ A $ 1:A9))),3 + 1)) 这样将A1:A9中的值乘以9个TRUE或FALSE。 TRUE将转换为1和FALSE为零。这样留下一个像这样的SUM函数 = SUM({0; 0; 0; 0; 0; 155; 0; 167 ; 201})/ 3由于155以上的所有值都不符合行号标准,得到乘以零。
I want to calculate a moving average of the last, say 20, numbers of a column. A problem is that some of the cells of the column may be empty, they should be ignored. Example:
A 175 154 188 145 155 167 201A moving average of the last three would be (155+167+201)/3. I've tried to implement this using average, offset, index, but I simply don't know how. I'm a little bit familiar with macros, so such a solution would work fine: =MovingAverage(A1;3)
Thanks for any tips or solutions!
解决方案 {=SUM(($A$1:A9)*(ROW($A$1:A9)>LARGE((ROW($A$1:A9))*(NOT(ISBLANK($A$1:A9))),3+1)))/3}Enter this with control+shift+enter to make it an array formula. This will find the latest three values. If you want more or less, change the two instances of '3' in the formula to whatever you want.
LARGE((ROW($A$1:A9))*(NOT(ISBLANK($A$1:A9))),3+1)This part returns the 4th highest row number of all the cells that have a value, or 5 in your example because rows 6, 8, and 9 are the 1st through 3rd highest rows with a value.
(ROW($A$1:A9)>LARGE((ROW($A$1:A9))*(NOT(ISBLANK($A$1:A9))),3+1))This part returns 9 TRUEs or FALSEs based on whether the row number is larger than the 4th largest.
($A$1:A9)*(ROW($A$1:A9)>LARGE((ROW($A$1:A9))*(NOT(ISBLANK($A$1:A9))),3+1))This multiplies the values in A1:A9 by those 9 TRUEs or FALSEs. TRUEs are converted to 1 and FALSEs to zero. This leaves a SUM function like this
=SUM({0;0;0;0;0;155;0;167;201})/3Because all the values above 155 don't satisfy the row number criterion, the get multiplied by zero.
更多推荐
计算Excel中的移动平均线
发布评论