+ Reply to Thread
Results 1 to 9 of 9

COUNTIFS with Date Calculations

  1. #1
    Registered User
    Join Date
    09-06-2018
    Location
    California, USA
    MS-Off Ver
    2016
    Posts
    20

    COUNTIFS with Date Calculations

    I'm trying to count the number of rows where the difference between two dates are greater than 30 days in addition to other criteria.



    Reported_Date Resolved_Date Group Tech Category YYYYMM
    43375.63483 43375.70711 PC-Group Tech 1 Low 201810
    43335.42803 43375.70961 NET-Group Tech 2 Medium 201809



    I can use COUNTIFS without issue to filter fields (Group, Tech, Category, YYYMM) but can't seem to work the date differential into the formula without using a helper field.

    Is there a way to do this?

    Thanks,

    John

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,943

    Re: COUNTIFS with Date Calculations

    =sumproduct(((b2:b1000-a2:a1000)>30)*1)
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    09-06-2018
    Location
    California, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: COUNTIFS with Date Calculations

    Sorry, I needed to clarify. I need to do this calculation along with filtering for the other fields.
    =countifs(C2:C4,"PC-Group",F2:F4,201809)
    but need to add the sumproduct formula to the mix or add the countifs to the sumproduct formula. Whichever works.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,943

    Re: COUNTIFS with Date Calculations

    =SUMPRODUCT(((C2:C4="PC-Group")*(F2:F4=201809)*((B2:B4-A2:A4)>30))*1)

    You can add as many conditions as you need by adding (range=x)* or ((Calc)=x)* sub-units to the SUMPRODUCT - just make sure your row counts match.

  5. #5
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: COUNTIFS with Date Calculations

    Try this
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-06-2018
    Location
    California, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: COUNTIFS with Date Calculations

    Strange.

    If I do
    =SUM(C23-B23)
    I get 31.98868. So the numbers work.

    But if I do the
    =SUMPRODUCT(C23:C30-B23:B30>30)
    I get 0.

    I tried this because I was getting 0 when trying the SUMPRODUCT with other criteria. This is my data. The first Date 1 is B23.

    Index Date1 Date2
    1 43274.69734 43306.68602
    2 43304.68601 43305.71149
    3 43304.61339 43315.68117
    4 43304.59642 43304.70284
    5 43304.52712 43307.46205
    6 43304.49925 43305.45123
    7 43304.4874 43305.58998
    8 43304.45787 43332.37057

  7. #7
    Registered User
    Join Date
    09-06-2018
    Location
    California, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: COUNTIFS with Date Calculations

    I got it. Had to do =SUMPRODUCT(--(C23:C30-B23:B30>30)) Time to try the additional criteria.

  8. #8
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,943

    Re: COUNTIFS with Date Calculations

    When you do

    =SUMPRODUCT(C23:C30-B23:B30>30)

    There is no "product" to sum It is just an array of TRUE and FALSE values.

    Using either

    =SUMPRODUCT(--(C23:C30-B23:B30>30))

    or

    =SUMPRODUCT((C23:C30-B23:B30>30)*1)

    Converts the TRUE/FALSE values to numbers (1s and 0s) which can then be summed.

  9. #9
    Registered User
    Join Date
    09-06-2018
    Location
    California, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: COUNTIFS with Date Calculations

    Thanks Bernie! I completely spaced on the *1
    *facepalm*

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Countifs &Date?
    By thursday140 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-06-2018, 09:56 PM
  2. Countifs match criteria and date is equals to or within date range
    By tiggi in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-28-2016, 11:00 AM
  3. Replies: 2
    Last Post: 05-28-2014, 06:52 AM
  4. Replies: 0
    Last Post: 12-16-2011, 09:01 AM
  5. Date calculations - adding number of days to a date
    By Dave Goldman in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 03-12-2011, 12:44 PM
  6. Date and time calculations and automatic date changes
    By Arlette in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-09-2006, 05:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1