简体   繁体   中英

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; 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:

Screenshot of Example Data File in Excel

Excel中的示例数据文件的屏幕截图 ):

Column A = Unique Order Numbers

Column B = Date and Time Service Requested

Column C = Date and Time Service Completed

Column D = Number of Technicians Responding

Column E = (calculated) Number of Technicians Unavailable

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? (This is an OR problem). 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).

Assume I have sorted my data by the date and time appearing in Column B, most recent first.

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). How do I get Excel to calculate the value 9 (cell E2 that I have currently manually summed)?

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.

=SUMIFS(D:D,C:C,">" & B2,A:A,"<" & A2) + SUMIFS(D:D,C:C,"",A:A,"<" & A2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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