+ Reply to Thread
Results 1 to 5 of 5

Formula to Match the Next Closest Date

  1. #1
    Registered User
    Join Date
    02-12-2021
    Location
    Beaverton, OR
    MS-Off Ver
    2011
    Posts
    5

    Formula to Match the Next Closest Date

    Cross-post link added by moderator: https://www.mrexcel.com/board/thread...-date.1170861/

    Hi,

    I'm trying to write a formula in Column F on Sheet1 to retrieve the record from Sheet2 with the next closest "Start Date" that is after the "End Date" on Sheet1.

    So ideally for Employee 526319, I would populate "2/15/2021" in Cell F10 in Sheet1 and "1/28/2021" in Cell F25.

    I tried doing this by creating a unique instance of each record as I have multiple Employee records with varying start and end dates on both sheets. In a normal circumstance, the (End Date - 1) on Sheet1 will match the Start Date on Sheet2, so my Unique columns match values. So either of these work for the normal circumstance:

    =INDEX(Sheet2!B:B,MATCH(Sheet1!E2,Sheet2!D:D,0))

    or =XLOOKUP(E2,Sheet2!D:D,Sheet2!B:B,0)

    But I can't seem to find anything that makes sense to me in order to retrieve record with the next closest date that is not exact. I tried doing something like this but this isn't making sense: =INDEX(Sheet2!E:E,MATCH(MIN(ABS(Sheet1!H16-Sheet2!E:E)),0))

    Any help would be much appreciated!
    Attached Files Attached Files
    Last edited by 6StringJazzer; 05-13-2021 at 03:04 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Formula to Match the Next Closest Date

    On rows 10 & 25 of sheet 1 the unique number does not exist on Sheet2.

    Perhaps it's the unique number that is wrong.

    If you use instead the Employee number then you'll get a match.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    02-12-2021
    Location
    Beaverton, OR
    MS-Off Ver
    2011
    Posts
    5

    Re: Formula to Match the Next Closest Date

    Yes, thanks. I realize the unique match does not exist, which is why I want to create a formula that looks at the closest date that is greater or equal to what is in Sheet 1, but needs to reference the same employee.
    I can have multiple records for the same employee but with different dates so that's why I created the unique column. I can't only use the employee number as the unique identifier because I have both sheets where there can be multiple records for the same employee.

    If I could eliminate the need of creating a 'unique' column, that would be preferrable - which is why I'm trying to do basically a ">=" check somewhere in my formula, - I tried to find the minimum absolute value of the difference between the start date on Sheet 2 - end date on Sheet 1 while still referencing the same employee, but not sure how.

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

    Re: Formula to Match the Next Closest Date

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    I have added the link for you since you are a new member. Please read the rules.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  5. #5
    Registered User
    Join Date
    02-12-2021
    Location
    Beaverton, OR
    MS-Off Ver
    2011
    Posts
    5

    Re: Formula to Match the Next Closest Date

    Thanks for letting me know! Will do in the future.

+ 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. Replies: 15
    Last Post: 10-29-2019, 06:46 AM
  2. Match Closest Date in a table but the date can't be after the lookup value
    By excelmelucy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-24-2019, 06:05 AM
  3. Closest date (index match)
    By farniajr in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 11-22-2018, 02:34 AM
  4. Replies: 2
    Last Post: 12-18-2014, 09:52 AM
  5. Match by ID number and closest date
    By Faith79 in forum Excel General
    Replies: 4
    Last Post: 06-30-2014, 02:29 AM
  6. Index with closest date and ID match
    By Beccah in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-19-2014, 06:01 AM
  7. Replies: 0
    Last Post: 08-25-2005, 02:37 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