+ Reply to Thread
Results 1 to 10 of 10

Average days over range of dates?

  1. #1
    Registered User
    Join Date
    06-21-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    Average days over range of dates?

    Hi All,

    I'm having big problems with what I thought would be a simple spreadsheet.

    I have set a sheet up to record when I change each ink cartridge in my printer, an example row would be something like:
    T5809 . Light Light Black . 23 July 2010 . 10 December 2010 . 20 February 2011 . <etc.>
    Obviously there will be a different number of dates for each ink.

    On a row under these, I want to have:
    Ink . Average Length of usage . Times Changed
    Needless to say, even I can manage the cartridge code and the change count, the average days however is proving itself to be a better man than me.

    My first thought was:
    =AVERAGE(D4:J4)
    But that just generates a five digit number that seems to have no relevance to the task. After a bit of Googleing, I tried about a dozen variants on that, and the normal response was:
    #VALUE!

    Any suggestion on how to accomplish this (simple?) task?

    ~John
    Last edited by JohnHolland; 06-21-2011 at 10:24 AM. Reason: Spelling (Doh!)

  2. #2
    Valued Forum Contributor
    Join Date
    11-15-2007
    Location
    England
    MS-Off Ver
    Office Pro 2003 / 2010
    Posts
    423

    Re: Average days over range of dates?

    Try this.

    Ssumes your dates are in B2, B3 & B4

    =DAYS360(B2,B4)/COUNTA(B2:B4)

  3. #3
    Registered User
    Join Date
    06-21-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Average days over range of dates?

    Hi
    Quote Originally Posted by timbo1957 View Post
    Try this.

    Ssumes your dates are in B2, B3 & B4

    =DAYS360(B2,B4)/COUNTA(B2:B4)
    Converted it to =DAYS360(C3,J3)/COUNTA(C3:J3) as the dates run horizontally rather than vertically. However for just two dates (23rd Feb '09 and 10th of Dec '10) it gives a number of minus 19646.5 clearly this isn't right, what am I doing wrong? (the dates are in C3 and D3 for this instance).

    -John

  4. #4
    Valued Forum Contributor
    Join Date
    11-15-2007
    Location
    England
    MS-Off Ver
    Office Pro 2003 / 2010
    Posts
    423

    Re: Average days over range of dates?

    Hi John,

    You aren't comparing apples with apples -

    Converted it to =DAYS360(C3,J3)/COUNTA(C3:J3)
    the dates are in C3 and D3
    Your range for your sum DAYS360(C3,J3)/COUNTA(C3:J3) is greater than the range of data which you say is in C3:D3.

    What this does is include a blank cell and the DAYS360 function can't find date in E,F,G,H,I,or J.

    If you need to include blank cells you could get around it by using CHOOSE

    The CHOOSE function in this case would use up the number generated by the COUNTA function to work out which sum to use the same for the second part of the sum.

    =CHOOSE(COUNTA(C3:J3),DAYS360(C3,C3),DAYS360(C3,D3),DAYS360(C3,E3),DAYS360(C3,F3),DAYS360(C3,G3),DAYS360(C3,H3),DAYS360(C3,I3),DAYS360(C3,J3))/CHOOSE(COUNTA(C3:J3),COUNTA(C3),COUNTA(C3:D3),COUNTA(C3:E3),COUNTA(C3:F3),COUNTA(C3:G3),COUNTA(C3:H3),COUNTA(C3:I3),COUNTA(C3:J3))

  5. #5
    Registered User
    Join Date
    06-21-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Average days over range of dates?

    Quote Originally Posted by timbo1957 View Post
    Hi John,

    You aren't comparing apples with apples -





    Your range for your sum DAYS360(C3,J3)/COUNTA(C3:J3) is greater than the range of data which you say is in C3:D3.

    What this does is include a blank cell and the DAYS360 function can't find date in E,F,G,H,I,or J.

    If you need to include blank cells you could get around it by using CHOOSE

    The CHOOSE function in this case would use up the number generated by the COUNTA function to work out which sum to use the same for the second part of the sum.

    =CHOOSE(COUNTA(C3:J3),DAYS360(C3,C3),DAYS360(C3,D3),DAYS360(C3,E3),DAYS360(C3,F3),DAYS360(C3,G3),DAYS360(C3,H3),DAYS360(C3,I3),DAYS360(C3,J3))/CHOOSE(COUNTA(C3:J3),COUNTA(C3),COUNTA(C3:D3),COUNTA(C3:E3),COUNTA(C3:F3),COUNTA(C3:G3),COUNTA(C3:H3),COUNTA(C3:I3),COUNTA(C3:J3))
    The idea was to just add dates when the ink was changed and let the spreadsheet work out the average and update itself. This seems a very un-elegant solution, but at least it seems to work, far more so than any of my attempts LOL the only problem now is I have two averages ending in point five (oddly enough one of which is from the two dates I listed earlier). Any idea what is happening there?

    Thank you so much for your help so far too.

    -John.

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

    Re: Average days over range of dates?

    I would avoid DAYS360 as it doesn't give an exact count of days....

    Try

    =(MAX(C3:J3)-MIN(C3:J3))/(COUNT(C3:J3)-1)

    format as general

    That copes with blanks in the range

    Note: the denominator has to have -1 because the number of periods is 1 less than the number of dates........
    Audere est facere

  7. #7
    Valued Forum Contributor
    Join Date
    11-15-2007
    Location
    England
    MS-Off Ver
    Office Pro 2003 / 2010
    Posts
    423

    Re: Average days over range of dates?

    Hi John,

    The difference in days between 23/07/10 and 10/12/10 is 137.

    You have made two purchases 137/ 2 = 68.5.

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

    Re: Average days over range of dates?

    Hello timbo, see my post below - I'm assuming John would want to average the length of periods between cartridge changes, in which case with only 2 dates the average will be the same as the difference, i.e. 137.....

  9. #9
    Valued Forum Contributor
    Join Date
    11-15-2007
    Location
    England
    MS-Off Ver
    Office Pro 2003 / 2010
    Posts
    423

    Re: Average days over range of dates?

    Understood.

  10. #10
    Registered User
    Join Date
    06-21-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Average days over range of dates?

    Hi

    All sorted, thanks for the help guy, much appreciated.

    -John

+ 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