+ Reply to Thread
Results 1 to 17 of 17

Averages

  1. #1
    Registered User
    Join Date
    01-31-2017
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    27

    Averages

    Hi, i have a problem, im trying to calculate the difference between 2 dates in 2 columns and displaying the total average of these days.
    For example:

    A B
    12-05-2015 30-05-2015
    14-05-2016 30-05-2016

    Average days between column A and B = y

    All in one single formula.

    please help...

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,421

    Re: Averages

    Try this:

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    10
    12/05/2015
    30/05/2015
    17
    11
    14/05/2016
    30/05/2016
    Sheet: Sheet1

    Excel 2016 (Windows) 32 bit
    D
    10
    =SUMPRODUCT((B10:B11)-(A10:A11))/COUNT(B10:B11)
    Sheet: Sheet1
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: Averages

    Depends on your worksheet set up. But you can do something like below.
    =SUMPRODUCT((B1:B2)-(A1:A2))/COUNT(A:A)

  4. #4
    Registered User
    Join Date
    01-31-2017
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    27

    Re: Averages

    gives me a negative number, maybe because of the empty cells? Im trying to do the entire column, so that it updates the data when a new line is added

    The column B may have empty cells
    Last edited by rukazer; 01-31-2017 at 11:03 AM.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,421

    Re: Averages

    So, give us some truly representative data to work with!

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,421

    Re: Averages

    Assuming you don't want to include rows with blanks in B:

    Excel 2016 (Windows) 32 bit
    D
    10
    =(SUM(B10:B12)-SUMIF(B10:B12,"<>",A10:A12))/COUNT(B10:B12)
    Sheet: Sheet1

  7. #7
    Registered User
    Join Date
    01-31-2017
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    27

    Re: Averages

    Thank you AliGW, that was brilliant, worked like a charm! =)

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,421

    Re: Averages

    You're welcome! Just got my logic cap on ...

  9. #9
    Registered User
    Join Date
    01-31-2017
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    27

    Re: Averages

    one more thing, following your formula
    =(SUM(B10:B12)-SUMIF(B10:B12,"<>",A10:A12))/COUNT(B10:B12)

    I want to create 2 cells, Initial Date and End Date. And by changing the dates on these cells, i wanted to show only the results between these dates, of the formula you created.

    I know im a being a pain, but my excel is really rusty, please help... :|

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,421

    Re: Averages

    Try this (untested, as I have only just got home from work):

    =(SUMIFS(B10:B12,A10:A12,">="&A1,B10:B12,"<="&B1)-SUMIFS(A10:A12,A10:A12,">="&A1,B10:B12,"<="&B1,B10:B12,"<>"))/COUNT(B10:B12)

  11. #11
    Registered User
    Join Date
    01-31-2017
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    27

    Re: Averages

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This is the formula im using (its in Portuguese) but the SUMIFS is the SOMA.SE.S and the COUNT is the CONTAR, C5 is the Initial Date and D5 the End Date.

    The formula gave me a large number like 459663,65. The average days should be around 12,1. When i change the dates from the cells C5 and D5 it also changes the result, but not close to the correct one.

  12. #12
    Registered User
    Join Date
    01-31-2017
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    27

    Re: Averages

    Nevermind, i found the problem! Your formula was flawless!

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,421

    Re: Averages

    That's good to know. Glad to have helped!

  14. #14
    Registered User
    Join Date
    01-31-2017
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    27

    Re: Averages

    On a closer look the values don't add up, the average should be 3,25 and the formula gives me 3,36. Also when i change the dates ate the bottom the Formula Result gives wierd numbers.
    Sorry for not posting an attachment but i think the function is not working.

    Please Login or Register  to view this content.
    The formula
    Please Login or Register  to view this content.
    Last edited by rukazer; 01-31-2017 at 01:58 PM. Reason: forgot code

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,421

    Re: Averages

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Averages

    Quote Originally Posted by rukazer View Post
    On a closer look the values don't add up, the average should be 3,25 and the formula gives me 3,36.

    Date
    01/01/2016 - 31/01/2017
    Based on your posted sample data the correct result is 3.35714285714286 or rounded to 2 decimal places 3.36.

    All of your data falls within your date range of 01/01/2016 - 31/01/2017.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  17. #17
    Registered User
    Join Date
    01-31-2017
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    27

    Re: Averages

    Quote Originally Posted by Tony Valko View Post
    Based on your posted sample data the correct result is 3.35714285714286 or rounded to 2 decimal places 3.36.

    All of your data falls within your date range of 01/01/2016 - 31/01/2017.
    Ok thanks im going to take a better look tomorrow at work

+ 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. Replies: 4
    Last Post: 03-13-2015, 05:34 AM
  2. Replies: 9
    Last Post: 05-15-2014, 01:57 PM
  3. Replies: 2
    Last Post: 02-29-2012, 09:34 PM
  4. How to get averages of already calculated averages
    By rosarionyc in forum Excel General
    Replies: 15
    Last Post: 12-29-2010, 03:05 PM
  5. Formula, Averages by name, and differences of averages
    By billyvnilly in forum Excel General
    Replies: 3
    Last Post: 02-24-2010, 05:35 PM
  6. Replies: 1
    Last Post: 05-02-2008, 10:41 AM
  7. averages
    By Metolius Dad in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-06-2006, 09:50 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