+ Reply to Thread
Results 1 to 14 of 14

running maximum time open

  1. #1
    Registered User
    Join Date
    05-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    running maximum time open

    I am trying to create a calculation of the maximum amount time any order of all orders is open. I would like to plot maximum time open (days) vs the date.
    The data I have looks something like below where an empty date closed cell indicates the order is still open. Thanks in advance for the help.
    (I just noticed the 3 column format is not maintained when actually posted. The date column is just a running list of dates)

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 05-19-2013 at 12:14 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: running maximum time open

    Based on the example data, please add your expected results and where it would appear. Show us the end goal you are trying to automate.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: running maximum time open

    The results from the sample data set would look something like the following. The only time something interesting happens is when the oldest order is closed.

    Please Login or Register  to view this content.
    Last edited by pdmbike; 05-20-2013 at 05:59 AM.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: running maximum time open

    Aw, EDIT your post #1 so you can see the CODE tags I used to make the formatting work, then use them in your posts, fix post #3. Be a quick learner....
    Last edited by JBeaucaire; 05-19-2013 at 11:06 PM.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: running maximum time open

    Maybe you should post a workbook with all this in it, including the answers, then explain how you got each one. How did you come to 2 in row 5? How did you come to 7 in rows 10 and 11?

  6. #6
    Registered User
    Join Date
    05-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: running maximum time open

    Edited the 2nd post. Thanks for the coaxing.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: running maximum time open

    I still can't resolve the answers you're giving using only the dates given above. Are you sure you're not inferring additional information from other columns not shown?

  8. #8
    Registered User
    Join Date
    05-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: running maximum time open

    I would like to plot the oldest open order based on the date opened and date closed vs all the dates in the past. So column 4 would be on the y axis and column 3 on the x axis. So for 5/1, nothing was open,
    5/2 one order was open that day, and it was zero days old.
    5/3 the order opened on 5/2 was 1 day old (another order was open, but it is not the oldest)
    5/4 the order opened on 5/2 was 2 days old....
    continues with 5/2 as the oldest report until it is closed on 5/10 on which day the 5/3 report becomes the oldest open.

    Ideally the automation would be done without macros. I am not sure I can get away with not using arrays though.

    Thanks again!

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: running maximum time open

    No, you won't get away from array formulas on this one. Why would you need to?

    I also can't fathom a solution that doesn't require you to sort the data by the first column. I'll ping some others to take a look.

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: running maximum time open

    there are surely simpler ways than
    cell D2: =IF(MIN(IF(($B$2:$B$7>C2)+($B$2:$B$7=""),IF($A$2:$A$7<=C2,$A$2:$A$7,""),""))=0,0,C2-MIN(IF(($B$2:$B$7>C2)+($B$2:$B$7=""),IF($A$2:$A$7<=C2,$A$2:$A$7,""),"")))
    array-entered with ctrl+shift+enter and then copied down
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: running maximum time open

    This gives me the correct answers

    =MAX(0,C2-MIN(IF((B$2:B$7>C2)+(B$2:B$7=""),A$2:A$7)))

    confirmed with CTRL+SHIFT+ENTER
    Audere est facere

  12. #12
    Registered User
    Join Date
    05-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: running maximum time open

    Thanks a bunch for the responses.
    Look for the smallest (oldest) then subtract from the date being analyzed.
    I think this works possibly unless there is nothing open.

  13. #13
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: running maximum time open

    Also be sure to test with a bunch of items with the same open date, but some closed and some not...

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

  14. #14
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: running maximum time open

    Quote Originally Posted by pdmbike View Post
    I think this works possibly unless there is nothing open.
    Joseph's suggestion handled that (if nothing is open it returns a zero). For mine you can tweak it to do the same - MIN always returns zero if there are no matching criteria but if you use SMALL instead then that will give an error if there is nothing open....and you can use IFERROR to generate the required value in that case, i.e.

    =IFERROR(MAX(0,C2-SMALL(IF((B$2:B$7>C2)+(B$2:B$7=""),A$2:A$7),1)),0)

    confirmed with CTRL+SHIFT+ENTER

    The zero at the end is what you get if there is nothing open

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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