+ Reply to Thread
Results 1 to 12 of 12

Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

  1. #1
    Registered User
    Join Date
    05-27-2020
    Location
    Melbourne
    MS-Off Ver
    2016
    Posts
    5

    Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    Hi folks,
    I'm trying to display the MAX, MIN and AVERAGE of a list of time intervals calculated form a range of dates/times. The Duration must remove weekends and holidays and display as days/hrs/mins. I have partial success as I can get this part to work using Networkdays function but the MAX, MIN will only display 0 values and the AVERAGE results in a #DIV/0! error.
    If I use a simple End-Start calculation for the interval then the MAX, MIN, AVERAGE will work. If I use Custom cell formatting I can get the days/hrs/mins but with only the number of days as a figure.
    Any ideas? Thank you in advance.

    Sampling interval1.png


    Cheers,
    Liam

  2. #2
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    Hi -

    I think your problem is when you add text to your results (" days ", etc.) Excel treats those values as text. So you can't do MIN, MAX or AVERAGE on text. Use Column E to hold your actual numerical data from your NETWORKDAYS formula, and calculate your statistics from that. Keep Column D as is for your pretty format.

    BUT, without a sample workbook to look at, I'm just guessing.

    Hope this helps.
    ____________________________________________
    If this has solved your problem, please edit the thread title to add the word [SOLVED] at the beginning. You can do this by
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

    If I have been particularly helpful, please "bump" my reputation by pressing the small star in the lower left corner of my post.

  3. #3
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    Those functions require numbers and can't work with text. So, your equation in column D needs to be a number. Use:
    ={the code above to give you the days}+TIME({the code above to give you hours},{the code above to give you minutes},0)
    This should show you a number like 6.493055556 for your 6 days, 11 hrs, 50 mins. Excel may try to be 'smart' and change the number format to 11:50 AM, which would not hurt anything, but it is easy to change the format back to 'General' so you see the 6.493 number. Now you can use the MAX, MIN, AVERAGE functions.

    You could also use some custom formatting to display it in your days-hrs-mins format (although it would have an issue if your time exceeded 31 days).
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  4. #4
    Registered User
    Join Date
    05-27-2020
    Location
    Melbourne
    MS-Off Ver
    2016
    Posts
    5

    Re: Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    Hi PauleyB,
    I've followed your suggestion but the result is not matching yours. My calculated result is 6.25416 rather that the expected result 6.493055556 for that line. Any ideas? I've tried it on other lines and they are all less than expected by manual calculation. Here is a screenshot of the formula in case I've done something stupid!

    Cheers,
    LiamSampling interval2.png

  5. #5
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    Post a sample sheet. See yellow banner

  6. #6
    Registered User
    Join Date
    05-27-2020
    Location
    Melbourne
    MS-Off Ver
    2016
    Posts
    5

    Re: Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    Hi arthurBr,
    I have attached a sample sheet...Sampling interval_
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    The MIN value can be returned with =MIN(IF(E2:E7>0,E2:E7) entered as an array formula with ctrl+ Shift +enter
    The average can be calculated with the AVERAGEIF function to exclude 0 values

  8. #8
    Registered User
    Join Date
    05-27-2020
    Location
    Melbourne
    MS-Off Ver
    2016
    Posts
    5

    Re: Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    Hi arthurbr,
    Thank you for that, but the catch is the values in Column E are not calculating correctly compared to Column D.
    So 6days 11hrs 50mins = 6.493055556 days, instead when I run the formula suggested by PauleyB above, my spreadsheet is calculating 6.25416667 days. The rest of the values in Column E are also less that the expected result if calculated manually.
    I've checked the 1904 date in File> Options> Advanced but it does not make a difference. I've removed the "-1" from the Time portion of the formula but again it doesn't bring it up far enough to match the expected result.

    Cheers,
    Liam

  9. #9
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    Is the attached what you need ?
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    05-27-2020
    Location
    Melbourne
    MS-Off Ver
    2016
    Posts
    5

    Re: Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    Hi arthurbr,
    That looks perfect, thank you so much. You made it look so easy.
    Did you ever find a reason for the original miscalculation? It's not really important but just a nice to know. I'm sure it's probably just a glitch somewhere.

    Vielen Danke,
    Liam

  11. #11
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    Sorry to have left the party, but I have two things to add:
    1) the bug in your code was that your equation used {the code to generate days} for both the days, hours, and minutes, so your time was really 6 days, 6 hours, and 6 minutes.
    2) the easy way to see this is to use Formulas Task Bar -> Formula Auditing -> Evaluate Formula. This let me step through your equation to see what it was calculating.

  12. #12
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Find MAX value from a range of time intervals displayed as "days", "hrs", "mins"

    You're welcome

+ 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] Brief formula to convert time values to "shift1", "shift2", "shift3".
    By darekpawel in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 04-11-2019, 07:05 AM
  2. Replies: 5
    Last Post: 02-05-2019, 12:03 AM
  3. Replies: 2
    Last Post: 07-24-2017, 02:19 AM
  4. [SOLVED] Column X-Ref list - Sheet1 Col A "pages", Col B:FL "Req" to Sheet2 ColA "req", ColB "page"
    By excel-card-pulled in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-07-2017, 09:30 AM
  5. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  6. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  7. Replies: 5
    Last Post: 06-26-2006, 09:23 PM

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