简体   繁体   English

Excel:使用2列之间的条件计算平均时间(持续时间)

[英]Excel: Calculate average time (duration), with criteria, between 2 columns

Breaking my head over this, time to look for help :( 打破我的头脑,时间寻求帮助:(

I have a sheet with raw data, as illustrated below. 我有一张包含原始数据的工作表,如下所示。
I'd like to calculate the average duration per TestName (column A) between the 2 timestamps (B and C) in another sheet. 我想计算另一张纸上两个时间戳(B和C)之间每个TestName(A列)的平均持续时间。

How can I do this in 1 formula? 如何在1个公式中做到这一点?

Note 1: The correct answer is (done manually) 注意1:正确答案是(手动完成)
test1 = 26:41:23 测试1 = 26:41:23
test2 = 08:23:10 test2 = 08:23:10

Note 2: 1 formula please, without adding extra columns to calculate the duration per each first 注意2:请使用1个公式,而不添加额外的列来计算每次第一次的持续时间
Note 3: I cannot change the format of the raw data 注意3:我无法更改原始数据的格式
Note 4: ignore empty fields 注4:忽略空字段

Thank you! 谢谢!

在此处输入图片说明

Use a new Column D to calculate the difference between start and end date on each row: 使用新的D列来计算每行开始日期和结束日期之间的差额:

=DATEVALUE(C2)+TIMEVALUE(C2) - (DATEVALUE(B2)+TIMEVALUE(B2))

Next calculate the average on test1 and test2 接下来计算test1和test2的平均值

=AVERAGEIFS($D:$D, $A:$A, "test1")
=AVERAGEIFS($D:$D, $A:$A, "test2")

Note that I'm using a comma as separator, in some languages, other separators, like semicolon are needed to write the formulas properly. 请注意,我使用逗号作为分隔符,在某些语言中,需要其他分隔符(例如分号)来正确编写公式。

Now format the view to display at least the days in addition to the time: "DD - hh:mm:ss". 现在,格式化视图以至少显示除时间以外的日期:“ DD-hh:mm:ss”。 Going beyond 31 days is a bit difficult as the month will count up. 超过31天会有些困难,因为该月会增加。 If you don't like the formatting, go with the raw number format and extract the information through a bit of math. 如果您不喜欢这种格式,请使用原始数字格式,并通过一些数学运算来提取信息。 If it shows for example 1,5 it means one and a half days. 如果显示例如1.5,则意味着一整天半。 I hope you can handle converting decimals to hours, minutes and seconds. 我希望您可以将小数转换为小时,分钟和秒。 MOD(ulo) and Rounddown are going to be your friends. MOD(ulo)和Rounddown将成为您的朋友。 :-) :-)

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

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