[英]Excel SUMIF with Date&Time Cells Compared to Array of Date&Time Cells (OR Statement)
I have found numerous examples online to use SUMIF and SUMIFS statements in Excel when comparing dates contained in a data set to fixed dates written in the formula; 当将数据集中的日期与公式中写入的固定日期进行比较时,我在网上发现了许多示例,可以在Excel中使用SUMIF和SUMIFS语句。 however, I am unable to locate information related to comparing dates contained in a data set to an array of other dates contained in a data set.
但是,我无法找到与将数据集中包含的日期与数据集中包含的其他日期的数组进行比较相关的信息。
Example scenario : 示例场景 :
Suppose I send technicians to complete services at multiple times throughout the day, and many of these service calls overlap. 假设我整天派技术人员多次完成服务,而这些服务电话中有许多重叠。 At the time that a new service call is received, I already have multiple technicians out at other calls.
接到新的服务电话时,我已经有多名技术人员在其他电话上。 I'd like to account for the number of technicians unavailable at the time a service call is received due to already being engaged in another call.
我想说明由于已经参与了另一个呼叫而在接到服务呼叫时不可用的技术人员的数量。
Here is an example data set format (direct image embedding not available for me yet: 这是示例数据集格式(直接图像嵌入尚不支持我:
):
):
Column A = Unique Order Numbers A列=唯一订单号
Column B = Date and Time Service Requested B列=请求的日期和时间服务
Column C = Date and Time Service Completed C列=完成日期和时间服务
Column D = Number of Technicians Responding D列=响应的技术人员数量
Column E = (calculated) Number of Technicians Unavailable E列=(计算得出)不可用的技术人员数量
Focused question : 重点问题 :
How do I sum the values in Column D, for which the date and time appearing in cell B2 is < any of the dates and times appearing in array C3:C9? 如何对D列中的值求和,对于这些列,B2中出现的日期和时间<数组C3:C9中出现的任何日期和时间? (This is an OR problem).
(这是一个OR问题)。 And then the calculations will need to be continued with each subsequent date and time appearing in Column B (eg, sum the values in Column D, for which the date and time appearing in cell B3 is < any of the dates and times appearing in array C4:C9).
然后需要继续进行计算,并在列B中显示每个后续日期和时间(例如,对列D中的值求和,为此,在单元格B3中出现的日期和时间<数组中出现的任何日期和时间) C4:C9)。
Assume I have sorted my data by the date and time appearing in Column B, most recent first. 假设我已经按照B列中出现的日期和时间对数据进行了排序,最近的是第一个。
In the example I have provided, order number 000008 was received on 09/30/2010 at 11:47:14 PM, but 9 technicians were still out engaged in other calls that were not completed by the time this new service call was received (yellow highlighted entries). 在我提供的示例中,订单号000008于2010年9月30日下午11:47:14收到,但是9名技术人员仍在忙于其他电话,这些电话在收到新服务电话时尚未完成(黄色突出显示的条目)。 How do I get Excel to calculate the value 9 (cell E2 that I have currently manually summed)?
如何获取Excel以计算值9(我当前手动求和的单元格E2)?
Thank you for your guidance. 感谢您的指导。
在单元格E2中,尝试以下操作:
=SUMIF(C2:$C$9, ">"&B2, D2:$D$9)
Assuming that you order by the order number (which is numeric and will be in order of request time) this formula should do the trick: 假设您按订单号订购(该数字是数字,并将按请求时间排序),则此公式应能解决问题:
=SUMIFS(D:D,C:C,">" & B2,A:A,"<" & A2)
This works by: 这是通过以下方式工作的:
= SUMIFS( D:D, /*Sum the Number of techs currently repsonding*/
C:C, ">" & B2, /* WHERE the completion date/time is less than the Request time for the current order */
A:A,"<" & A2) /* AND the order number is less than the current order number --Could alternatively use column B:B as the range and B2 as the critera */
Edit: Also need to count the datetime of the above records if the completion date is null. 编辑:如果完成日期为null,则还需要计算上述记录的日期时间。
=SUMIFS(D:D,C:C,">" & B2,A:A,"<" & A2) + SUMIFS(D:D,C:C,"",A:A,"<" & A2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.