+ Reply to Thread
Results 1 to 9 of 9

Count if a specific date value exists in a range of two columns

  1. #1
    Registered User
    Join Date
    02-17-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    14

    Count if a specific date value exists in a range of two columns

    I have a spreadsheet that is counting due dates by specific date. In column E, I have the original "Due Date". Column F could contain a "Revised Due Date" only if I have to revise the due date. I'm keeping them in separate columns because we don't want to lose track of what the original due date was, and we do want data that shows if we had to revise the due date.

    I'm trying to come up with a formula that looks at both cells on the same row in Column E and Column F, and if either one contains a specific date, it would count it.

    For example, if I'm trying to count the number of instances I have a due date of January 4, 2021, and the date of January 4, 2021 exists in Column E/line 11, and no date exists in Column F/line 11, it should be counted. However, if a different date exists in Column E/line 11 but the January 4, 2021 date exists in Column F/line 11, it should still be counted.

    Right now, the formula I have is:

    =COUNTIFS(Sheet1!F11,"",Sheet1!E11,DATE(2021,1,4))

    In this scenario, it's counting 1 if Cell E11 has a date of January 4, 2021 and Cell F11 is empty. The logical thought I had was that where I have the criteria for empty (""), I replace it with the 1/4/2021 date instead. But then it's only yielding a count if BOTH cells contain that date, and I want it to count if EITHER cell contains that date. There will not be an instance where both cells contain the same date. So it should yield a count of 1 if either the value in column E or the value in column F is the specified date.

    I cannot figure out how to write that formula. I can't figure a way to do a COUNTIFS(OR formula. Anyone know what will work?

    Thanks in advance!

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,457

    Re: Count if a specific date value exists in a range of two columns

    To test whether E11 or F11 contains specific date:

    With A1 contains specific date.

    =OR(E11=A1,F11=A1) yields "true" if match

    =OR(E11=A1,F11=A1)+0 yields 1 if match

    use which ever you want.
    Quang PT

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Count if a specific date value exists in a range of two columns

    The formula you showed is only looking at two specific cells in one row, not ranges of cells. If you are looking for an answer only for one row you don't have to use COUNTIFS.

    =IF(OR(Sheet1!F11=DATE(2021,1,4),Sheet1!E11=DATE(2021,1,4)),1,0)

    Will give you 0 or 1.

  4. #4
    Registered User
    Join Date
    02-17-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Count if a specific date value exists in a range of two columns

    I'm actually working in a range of cells so have to use COUNTIFS. Therefore, E will always have a date and it could be a date match, but F will only occasionally have a date, and if it does, I'd need it to be counted in a date match, and I'd need any matching dates in E that have a date next to them in F to not be counted.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Count if a specific date value exists in a range of two columns

    Quote Originally Posted by kbenderil View Post
    I'm actually working in a range of cells so have to use COUNTIFS.
    That doesn't make sense in light of the formula you provided. If we ignore that formula and just look at the columns:

    If you want to count all matches in both columns:

    =COUNTIF(Sheet1!E:E,DATE(2021,1,4))+COUNTIF(Sheet1!F:F,DATE(2021,1,4))

    One crucial note: This solution depends on your statement that:
    There will not be an instance where both cells contain the same date.
    Last edited by 6StringJazzer; 12-18-2020 at 12:03 PM. Reason: Changed from COUNTIFS to COUNTIF due to syntax (wrong formula anyway)

  6. #6
    Registered User
    Join Date
    02-17-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Count if a specific date value exists in a range of two columns

    So column E is "Due Date". Column F is "Revised Due Date". For historical purposes we don't want to delete the value in column E if a revised due date is entered next to it in Column F. So, in the formula it's looking for the date value of 1/4/2021 and counting it as an instance. However, if on the same row, I have an original due date (column E) of 1/4/2021, and there's a revised due date (which will never be the same as the original, or this cell will be empty if there's no revised due date), I want the fact that there's a date value in F on the same row to "not count" the matching date in column E. However, I want a formula that will still count instances of 1/4/2021 in Column F (revised due date).

    In other words, if there's a match in column E but column F on the same row as that match has a value, don't count the match in column E. But, it's also looking for date matches in Column F and counting those.

    It's like I need an IF/OR for a COUNTIFS formula where I can say, if there's a match in E with no value in F, count it. If there's a match in E but a value in F, don't count it. If there's a match in F, count it.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Count if a specific date value exists in a range of two columns

    I see. So if column E matches 1/4/2021, but the date is revised in column F, you do not want to count the match in column E. That is very helpful.

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


    This assumes that if the matching date is found in column F, it will not be the same date as column E.

    I think this could also be done with an array formula using booleans but the above certainly works.

  8. #8
    Registered User
    Join Date
    02-17-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Count if a specific date value exists in a range of two columns

    Thank you! That solved the problem! I don't know how to mark this as solved but it is SOLVED!

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Count if a specific date value exists in a range of two columns

    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking on the star icon addreputationiconsmall.jpg below their name.

+ 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] count value within specific date range
    By 323100N in forum Excel General
    Replies: 3
    Last Post: 01-17-2019, 09:16 AM
  2. [SOLVED] Count of specific values in a date range
    By bobbych in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 11-25-2015, 06:00 AM
  3. [SOLVED] Count cells within a specific date range that contain a specific word
    By oneillp1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-23-2014, 08:34 AM
  4. Replies: 1
    Last Post: 02-05-2013, 09:14 AM
  5. count specific days within date range
    By Sazza in forum Excel General
    Replies: 3
    Last Post: 03-27-2012, 09:04 AM
  6. Formula for determining if two date columns fall within specific date range
    By Igottabeme in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-20-2006, 09:55 PM
  7. Replies: 1
    Last Post: 04-20-2006, 05:10 PM

Tags for this Thread

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