简体   繁体   English

在 2 个时间范围之间对一列中的行求和

[英]Sum rows in one column between 2 time range

Is there a way to sum values in a column between two different time.有没有办法在两个不同时间之间对列中的值求和。 The two different hrs are different for different start and end calculation.这两个不同的小时对于不同的开始和结束计算是不同的。 The formula i used is =SUMIFS(Period,time,">="&Time Range,time, Range,"<="&Time Range) , but the formula returns only the first hour value but the expected result should be between total of start calc and end cal value我使用的公式是=SUMIFS(Period,time,">="&Time Range,time, Range,"<="&Time Range) ,但该公式仅返回第一个小时值,但预期结果应介于 start 总数之间calc 和 end cal 值

time          period  Cal stat    Time Range       Expected Result
6:37:02 AM      1     start calc  6:37:02 AM     4
6:37:03 AM      1     no action     0   
6:37:04 AM      2     End Calc    6:37:04 AM
6:37:06 AM      1     Start Calc  6:37:06 AM     6
6:37:07 AM      1     no action     0 
6:37:08 AM      2     no action     0
6:37:10 AM      1     no action     0
6:37:11 AM      1     End Calc    6:37:11 AM
6:37:12 AM      2     Start Calc   6:37:12 AM     3
6:37:14 AM      1     End Calc     6:37:14 AM 
6:37:15 AM      1     no action     0    
6:37:16 AM      1     no action     0
6:37:17 AM      2     no action     0
6:37:19 AM      2     no action     0

I don't know about doing it with SUMIFS .我不知道用SUMIFS来做。

However, with INDEX(MATCH(… , you can construct a formula that will sum from the current row to the next "end Calc" , and use an IF(… to only show results in the start calc rows.但是,使用INDEX(MATCH(… ,您可以构造一个公式,从当前行求和到下一个"end Calc" ,并使用IF(…仅在start calc行中显示结果。

E2: =IF(C2="start calc", SUM( INDEX(B2:$B$15,1):  INDEX(B2:$B$15,MATCH(TRUE,C2:$C$15="end Calc",0))),"")
  • Fill the formula down as far as needed根据需要填写公式
  • The $15 row numbers in the formula can be changed to any row that is at least as large as your expected table, but be sure it remains an absolute address.公式中的$15行号可以更改为至少与预期表一样大的任何行,但请确保它仍然是绝对地址。
    • eg: =IF(C2="start calc", SUM( INDEX(B2:$B$1500,1): INDEX(B2:$B$1500,MATCH(TRUE,C2:$C$1500="end Calc",0))),"")例如: =IF(C2="start calc", SUM( INDEX(B2:$B$1500,1): INDEX(B2:$B$1500,MATCH(TRUE,C2:$C$1500="end Calc",0))),"")

在此处输入图像描述

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

相关问题 需要将日期从一列复制到另一列,以获得两个不同颜色行之间的一系列行 - Need to copy date from one column into another column for a range of rows between two different colored rows 通过单独的列查找来计算一系列行 - SUM a range of rows by looking up by a separate column 对日期范围内具有值上限的列求和 - Sum a column between a date range with a value cap 合并行,对一列值求和,并保持最早的开始时间和最新的结束时间-第2部分 - Merge rows, sum one column of values, and keep earliest start time and latest end time - Part 2 合并行,对一列值求和,并保持最早的开始时间和最新的结束时间 - Merge rows, sum one column of values, and keep earliest start time and latest end time Excel:需要根据一列上两列(日期之间)的日期范围求和 - Excel: Need to sum based on date range in two columns (between dates) over one column VBA总和可变范围,变量范围和总和之间有一些空行 - VBA sum variable range with some empty rows between variable range and sum 如果一列在两个日期之间,则求和 - Sum one column if it is between two dates 在另一列中查找包含相同值的行的总和 - Find sum in one column for rows containing the same value in another column Excel如何求和范围,即多于一列? - Excel How to sum range, which is more than one column?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM