计算Excel中的移动平均线

编程入门 行业动态 更新时间:2024-10-26 12:33:23
本文介绍了计算Excel中的移动平均线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想计算最后一个移动平均线,即20个数字的列。一个问题是列的某些单元格可能是空的,它们应该被忽略。示例:

A 175 154 188 145 155 167 201

A最后三次的移动平均线将为(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 201

A 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})/3

Because all the values above 155 don't satisfy the row number criterion, the get multiplied by zero.

更多推荐

计算Excel中的移动平均线

本文发布于:2023-10-15 02:29:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1492986.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:平均   Excel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!