+ Reply to Thread
Results 1 to 12 of 12

Averaging out data from a DATEDIF Formula

  1. #1
    Registered User
    Join Date
    08-01-2007
    Posts
    32

    Averaging out data from a DATEDIF Formula

    Hi All,

    Im going insane trying to figure out how to Average out the data i've accumulated with the DATEDIF Formula...Can anyone please clarify if this is even possible ??

    Here's the situation...

    I've got a range of data that has been calculated by using the DATEDIF Function (below):

    Please Login or Register  to view this content.
    This is working fine, im getting the desired results (eg: '3 Years, 5 Months')...however, i now need to calculate the average of my DATEDIF Results and none of the formula's i try seem to work ??

    I've attached a small example of the Table that needs to be populated...Column E just needs to display the average of all the data in Column D...

    Thanks in Advance for any help you can provide.

    Cheers - Darren
    Attached Files Attached Files
    Last edited by DarrenH; 04-10-2008 at 03:10 AM. Reason: Error attaching Book1

  2. #2
    Registered User
    Join Date
    08-01-2007
    Posts
    32
    ...Bump...

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Once you concatenated your data in column C to achieve your desired formatting, everything becomes a string (text) and thus Excel can't do numerical calculations on it. Can you have a hidden column with the DATEDIF formula without any extraneous formatting and use that to calculate your average?

    ChemistB

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    If you want an average of rows 2 to 6 you can use

    =DATEDIF(AVERAGE(B2:B6),AVERAGE(C2:C6),"M")&" Months, " &DATEDIF(AVERAGE(B2:B6),AVERAGE(C2:C6),"md")&" Days"

  5. #5
    Registered User
    Join Date
    08-01-2007
    Posts
    32
    ChemistB - Cheers for the reply.

    I may be doing it wrong but i did try:
    Please Login or Register  to view this content.
    Which gave me a numerical result (eg: 3.2)...however when i try to calculate the average of these results i get the "#DIV/0!" error (i was was just using a straight forward Average function tho, below)
    Please Login or Register  to view this content.
    Where am i going wrong, does it have something to do with the "." that i've included into the formula ??

  6. #6
    Registered User
    Join Date
    08-01-2007
    Posts
    32
    Daddylonglegs - Cheers for the Reply

    I'll need to use that piece of Code later on in the spreadsheet im developing, so thanks !!

    As for now tho, the data i need to Average out only sits in the one Column.

    Im still open to suggestions tho

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    I'm not sure I understand, then. What are you trying to average in E2, what result would you expect for your example?

  8. #8
    Registered User
    Join Date
    08-01-2007
    Posts
    32
    Hmmm...apologies, I mis-read your reply...

    I've used your Code, which will work (i just had to make the cell references Absolute). It's just a completely different way to how i saw it happening.

    Just so i can clariy this for future reference:
    You cant average out a range of cells if you've used a formula to concatenate the desired result ?

    Or, will only work if you combine the Average function into the formula your developing ??

  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    As ChemistB says, you can't average text. If you showed the difference in days only, e.g. by using a formula like this in D2

    =C2-B2

    then this would be a numeric result which you could average.....or to get an approximation in months

    =(C2-B2)/30.5

    Incidentally you could get the same result as the previous formula I posted by using

    =AVERAGE(B2:B6)

    in cell B7 copied across to C7 and then in D7

    =DATEDIF(B7,C7,"M")&" Months, " &DATEDIF(B7,C7,"md")&" Days"

  10. #10
    Registered User
    Join Date
    08-01-2007
    Posts
    32
    Thanks DLL...

    I managed to incorporate what you provided to retrieve the results i need...However !!

    Some of the Cells in Column C are Blank (eg: the employee hasnt finished their testing yet, so the completion date doesnt exist)...

    What can i incorporate into the formula that will "identify when a cell is blank" and then "disregard the entire row" from the Averaging ??

    Is this possible to achieve with formula's in Excel, or does it have to be completed through VBA ??

    I have limited VBA Knowledge, but with the right code i could set it up to work...

    Cheers - Darren

  11. #11
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Hi Darren,

    To check first if a cell in C is blank, you'll need to add an IF statement to the formula that DLL has given you. IF statements follow the following format
    Please Login or Register  to view this content.
    So it would look something like this in your case
    Please Login or Register  to view this content.
    or in English if C2 is blank ("") then leave this cell blank, otherwise perform the formula.

    Note: Your formula
    Please Login or Register  to view this content.
    might look like a number but it's still a string to Excel. If you wanted to average the months and the days like that, you'd need to put each piece into a separate column e.g
    Please Login or Register  to view this content.
    Hope this helped.

    ChemistB

  12. #12
    Registered User
    Join Date
    08-01-2007
    Posts
    32
    Thanks ChemistB,

    Cheers for your help with this one guys - i've got it running like a dream !! (for now)...

    Appreciate it

    Regards - Darren

+ 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