+ Reply to Thread
Results 1 to 21 of 21

Finding the relative position of the date that closet matches a target date

  1. #1
    Registered User
    Join Date
    11-12-2019
    Location
    Houston, Texas
    MS-Off Ver
    Office 365 32-bit
    Posts
    6

    Finding the relative position of the date that closet matches a target date

    Hi All,

    I am trying to figure out a formula that will help me find the relative position of the largest date that is equal to or less than a provided selected date. In the attached you will see a list of projects that have column headers of stages 1 - 5 and a current stage. I am trying to get column H (the Current Stage column) to indicate which stage the project is in based on a selected date.

    So far I tried the below formulas (Using Project 4 as example), but neither work for all the possible scenarios for dates.

    =INDEX($C$2:$G$2,MATCH($J$3,C6:G6,1))

    and

    =INDEX($C$2:$G$2,MATCH(MAXIFS(C6:G6,C6:G6,"<="&$J$3),C6:G6,0))


    The two issues I am running into is that:

    1) dates may not be chronological with stage dates. So stage 1 may have a later date than stage 5 (like Project 3).
    2) the same date might be used for multiple stages (Like Project 2 and Project 4).

    The two issues make the formulas I came up with produce incorrect results. Does anybody have a suggestion on a formula that might work for all the projects listed?
    Attached Files Attached Files
    Last edited by PetPartner; 11-12-2019 at 06:29 PM.

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding the relative position of the date that closet matches a target date

    Hello PetPartner. Welcome to the forum.

    Your workbook is apparently protected and is not visible upon download.

    Can we try again?
    Dave

  3. #3
    Registered User
    Join Date
    11-12-2019
    Location
    Houston, Texas
    MS-Off Ver
    Office 365 32-bit
    Posts
    6

    Re: Finding the relative position of the date that closet matches a target date

    Thanks for the response Flame. I edited the post and removed and reattached the file. I didn't set any specific password protections on this file.

    Let me know if you can see the attachment on the updated post.

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding the relative position of the date that closet matches a target date

    Still not working. All I get is blue screen as if hidden. It is not on the 'Unhide' list.

    I've never seen this before.

    Calling for help.

  5. #5
    Registered User
    Join Date
    11-12-2019
    Location
    Houston, Texas
    MS-Off Ver
    Office 365 32-bit
    Posts
    6

    Re: Finding the relative position of the date that closet matches a target date

    I'm sorry to hear that. This is my first post so maybe I am uploading the file incorrectly somehow?

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding the relative position of the date that closet matches a target date

    Very unlikely.

    Since other files are uploading I suspect there is some obscure setting at my end that needs attention ... or there is a "hiccup" in the forum system.

    I've called for help. It's near day's end and later so this may take a while.
    Last edited by FlameRetired; 11-12-2019 at 06:50 PM.

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Finding the relative position of the date that closet matches a target date

    Hey PetPartner welcome to the forum,

    See if this answer helps you. It is a CSE (Control+Shift+Enter) or Array formula. To find the date you want (closest to given in J) you might use this.

    =MIN(ABS(C3:G6-$J$3)) (must use CSE to enter)

    Then the answer is either plus or minus that minimum. See the attached.

    CSE Minimum date.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,855

    Re: Finding the relative position of the date that closet matches a target date

    @Dave.

    I am able to open and view the file without issue. Will save and upload here for you.

    Alan
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding the relative position of the date that closet matches a target date

    Marvin, I am having the same problem downloading your attachment as well.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,336

    Re: Finding the relative position of the date that closet matches a target date

    Nothing wrong with the workbook as far as I can see. I can see the data and formulae and can edit them.

    Can't offer a solution to the problem off the top of my head.

    @FR: maybe reload Excel and/or reboot the computer?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding the relative position of the date that closet matches a target date

    @ Alan

    Thank you for that. It's still not downloading/opening.

    It displays as my PERSONAL.XLSB file does when hidden.

  12. #12
    Registered User
    Join Date
    11-12-2019
    Location
    Houston, Texas
    MS-Off Ver
    Office 365 32-bit
    Posts
    6

    Re: Finding the relative position of the date that closet matches a target date

    I appreciate the response Marvin! Unfortunately, I don't think this accomplishes my goal of finding the relative position for the date closet to the target date for each project. In the end, I am trying to make a formula that will provide the relative position of the date that closet match the selected date (Without being older than the selected date) so I can use it for a index match formula.

    Or to put in other words, I want column H to show the current stage based on the date inputted in J3.

  13. #13
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding the relative position of the date that closet matches a target date

    Thank you Trevor. Should have thought of that myself. It did the trick.

  14. #14
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Finding the relative position of the date that closet matches a target date

    Last edited by MarvinP; 11-12-2019 at 07:08 PM.

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,336

    Re: Finding the relative position of the date that closet matches a target date

    @FR: You're welcome. Thanks for the rep.

    Second pair of eyes

  16. #16
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding the relative position of the date that closet matches a target date

    Try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 11-12-2019 at 07:24 PM.

  17. #17
    Registered User
    Join Date
    11-12-2019
    Location
    Houston, Texas
    MS-Off Ver
    Office 365 32-bit
    Posts
    6

    Re: Finding the relative position of the date that closet matches a target date

    This seems to work! Thank you Dave!

    If it's not too much trouble, can you explain how this is working?

  18. #18
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding the relative position of the date that closet matches a target date

    I will do my best.

    I rely heavily upon the F9 function key and Evaluate formula feature (Fx).

    The following focuses on the case of cell H6 where there are duplicate MAX values in C6:G6.

    The "heart" of this formula is the (MAXIFS(C6:G6,C6:G6,"<="&$J$3)=C6:G6) part. MAXIFS of course returns the max value in C6:G6 that is less than or equal to $J$3. That part just mentioned compares that maximum value to all the values in C6:G6 to check for equality. Select just that part above in the formula bar and hit the F9 function key.

    You will see an array of TRUE/FALSE {TRUE,TRUE,FALSE,FALSE,FALSE}. If you are not aware of it when TRUE/FALSE is subjected to math operations it coerces T/F into their underlying values of 1/0. Reciprocation does that. 1/(MAXIFS(C6:G6,C6:G6,"<="&$J$3)=C6:G6). In this case it also creates an array of 1s and #DIV/0! errors. Select just the reciprocation 1/(MAXIFS(C6:G6,C6:G6,"<="&$J$3)=C6:G6) in the formula bar and hit the F9 again. You will see ...

    {1,1,#DIV/0!,#DIV/0!,#DIV/0!}

    LOOKUP will match the right most value in that array that is less than or equal to the lookup value ... 2 in this case. Since LOOKUP is one of the few functions that ignore errors it will match the right most 1. It then returns the corresponding value from the range in the last LOOKUP argument $C$2:$G$2 where the "Stage " headers are. Although there are two qualifying maximum values LOOKUP matches the right most one.

    You can also follow the calculation steps using the Evaluate formula feature ... FORMULAS > Evaluate formula. If you are not already familiar with them F9/Fx are helpful for analyzing, trouble shooting and self instruction. I recommend them both whenever I can.

    I hope this helps.

  19. #19
    Registered User
    Join Date
    11-12-2019
    Location
    Houston, Texas
    MS-Off Ver
    Office 365 32-bit
    Posts
    6

    Re: Finding the relative position of the date that closet matches a target date

    Thank you for the explanation! It really helped me understand what is going on. My difficulty was understanding how the DIV/0 errors didn't break the formula. I never seen that work in another formula.

  20. #20
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding the relative position of the date that closet matches a target date

    You are welcome. Glad to help, and thank you for the feedback.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  21. #21
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Finding the relative position of the date that closet matches a target date

    Please try at H3

    Please Login or Register  to view this content.
    Press Ctrl-Shift-Enter for ARRAY formula.


    Regards.

+ 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. Find Closet date in Pivot Table
    By charlesfarrell in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 11-19-2017, 10:22 PM
  2. [SOLVED] Finding the relative position of the last X
    By Howlin in forum Excel General
    Replies: 3
    Last Post: 09-02-2015, 09:11 AM
  3. Finding matches between two date arrays
    By cpranov in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-08-2011, 10:15 AM
  4. Finding a date closest to the target date.
    By shakes347 in forum Excel General
    Replies: 11
    Last Post: 09-08-2010, 02:45 PM
  5. Finding Matches within Date Ranges
    By jkalfsbeck in forum Excel General
    Replies: 6
    Last Post: 03-05-2010, 09:55 AM
  6. Finding Date and Position Cursor
    By ExcelQuestFL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-07-2009, 11:12 AM
  7. Finding the Relative Position of Numbers within a String
    By ExcelTip in forum Tips and Tutorials
    Replies: 0
    Last Post: 08-23-2005, 04:05 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