简体   繁体   English

按月计算标准差

[英]calculate standard deviation by month

I am trying to calculate standard deviation by month from daily data. 我正在尝试根据每日数据按月计算标准差。 I used this function and it's not working (It's returning %DIV/0! ). 我使用了此函数,但它不起作用(返回%DIV/0! )。

{=STDEV.S(IF(AND(MONTH(data!$A$5:$A$3893)=MONTH($I22),YEAR(data!$A$5:$A$3893)=YEAR($I22)),data!H$5:H$3893,0))}

Can you help me about this? 您能帮我吗?

Thanks 谢谢

The problem is that AND doesn't work well with array formulas. 问题是AND不能与数组公式配合使用。 Replace it with a multiplication. 用乘法代替它。 Also, remove the 0 in the false part of the if so that it won't ruin your computation: 另外,在if的false部分中删除0,以免破坏您的计算:

{=STDEV.S(IF((MONTH(data!$A$5:$A$3893)=MONTH($I22)) *
  (YEAR(data!$A$5:$A$3893)=YEAR($I22)), data!H$5:H$3893))}

The problem is that you can't use the AND operator in an array formula (since it tries to combine all the values into a single true or false). 问题是您不能在数组公式中使用AND运算符(因为它试图将所有值组合为单个true或false)。

Also by using 0 as your false value you are introducing false readings. 同样,通过使用0作为您的错误值,您将引入错误的读数。 Use a text value instead which stdev.s ignores. 使用文本值代替stdev.s忽略的文本值。

Try {=STDEV.S(IF(MONTH(data!$A$5:$A$3893)=MONTH($I22),if(YEAR(data!$A$5:$A$3893)=YEAR($I22),data!H$5:H$3893,""),""))} 尝试{=STDEV.S(IF(MONTH(data!$A$5:$A$3893)=MONTH($I22),if(YEAR(data!$A$5:$A$3893)=YEAR($I22),data!H$5:H$3893,""),""))}

The AND function as used in your formula will combine the month and year tests instead of applying them separately. 公式中使用的AND函数将合并月份和年份测试,而不是单独应用它们。 Use cascading IFs to avoid this. 使用级联IF可以避免这种情况。 Also, using zero for the case where the IF is false will probably give the wrong standard deviation, because 此外,如果IF为假,则使用零可能会给出错误的标准偏差,因为

STDEV.P(1,2,3,0,0,0,0,0) <> STDEV.P (1,2,3). 

Try this: 尝试这个:

=STDEV.S(IF(MONTH(data!$A$5:$A$3893)=MONTH($I22),IF(YEAR(data!$A$5:$A$3893)=YEAR($I22),data!H$5:H$3893,"NO"),"NO"))

The "NO" 's in the formula can be any text. 公式中的“ NO”可以是任何文本。 When Excel's statistical functions (SUM, AVG, STDEV, etc) encounter a text value, they skip it instead of converting it to zero. 当Excel的统计函数(SUM,AVG,STDEV等)遇到文本值时,他们将其跳过而不是将其转换为零。

STDEV.P(1,2,3,"NO","NO","NO","NO","NO") == STDEV.P(1,2,3)!!!

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

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