简体   繁体   English

我如何计算每小时的平均值?

[英]How can i calculate the average per hour?

I need to plot my data, but just a value per hour, the problem here is sometimes I have just one value at that hour, but other times I can have 4 our 5 readings at the same hour; 我需要绘制数据,但每小时仅一个值,这里的问题是有时我在那个小时只有一个值,但是其他时候我可以在同一小时获得4个5个读数; so How can I calculate the average per hour? 那么如何计算每小时的平均值?

thanks! 谢谢!

在此处输入图片说明

Assuming date/times in A2 down and values in B2 down try this formula in C2 假设A2向下的日期/时间和B2向下的值,请在C2尝试此公式

=AVERAGEIFS(B:B,A:A,">="&FLOOR(A2,"1:00"),A:A,"<"&CEILING(A2,"1:00"))

FLOOR function will round down to the hour and CEILING will round up so this averages between 01:00 and 02:00 etc. FLOOR函数将向下舍入到小时,而CEILING将向上舍入,因此其平均值在01:0002:00之间,以此类推。

The above version will give you the average on every row (with repeats). 上面的版本将为您提供每行的平均值(重复)。 If you alter it like this then the average will only appear on the last value for each hour 如果您这样更改,则平均值只会出现在每小时的最后一个值上

=IF(FLOOR(A2,"1:00")<>FLOOR(A3,"1:00"),AVERAGEIFS(B:B,A:A,">="&FLOOR(A2,"1:00"),A:A,"<"&CEILING(A2,"1:00")),"")

You can use a Pivot Chart. 您可以使用数据透视图。

Drag Date/Time to rows and it will probably automatically group by hours. 将日期/时间拖到行中,它可能会自动按小时分组。 If it doesn't you can enable that. 如果没有,您可以启用它。

Then drag the Values column to Values, and select to show the Average 然后将“值”列拖动到“值”,然后选择以显示“平均值”

在此处输入图片说明

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

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