+ Reply to Thread
Results 1 to 9 of 9

Calculate Averages

  1. #1
    Registered User
    Join Date
    03-02-2010
    Location
    Massachusetts, United States
    MS-Off Ver
    Excel 2003
    Posts
    11

    Calculate Averages

    Hi,

    I need to create a formula to use each month to calculate the averages base on date ranges. I was able to create a formula to sum the data, base on the date range. However, that's just half of the equation. I need help with the countif formula, to add to my formula. Please see attached spreadsheet.

    I want to be able to paste new data each month, in the grey cells, and have the averages calculate in the yellow cells.

    Please help,
    Dee
    Attached Files Attached Files
    Last edited by davesexcel; 07-06-2010 at 10:55 PM.

  2. #2
    Forum Contributor
    Join Date
    05-16-2010
    Location
    UK
    MS-Off Ver
    2003 and 2007
    Posts
    252

    Re: Calculate Averages

    In your example.

    B77: =SUM(IF(TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$73,"mm-yyyy"),$B$4:$B$70))/COUNT(IF(TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$73,"mm-yyyy"),1))

    B78: =SUM(IF(TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$74,"mm-yyyy"),$B$4:$B$70))/COUNT(IF(TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$74,"mm-yyyy"),1))

    ... confirm both formulas with Ctrl+Shift+Enter

    EDIT:

    or

    B77: =SUMPRODUCT((TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$73,"mm-yyyy"))*$B$4:$B$70)/SUMPRODUCT((TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$73,"mm-yyyy"))*1)

    B78: =SUMPRODUCT((TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$74,"mm-yyyy"))*$B$4:$B$70)/SUMPRODUCT((TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$74,"mm-yyyy"))*1)

    I am assuming you are calculating the average over the number of days in the month.

    If you are averaging on the values in column B then:

    B77: =SUM(IF(TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$73,"mm-yyyy"),$B$4:$B$70))/COUNT(IF((TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$73,"mm-yyyy"))*($B$4:$B$70<>""),1))

    B78: =SUM(IF(TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$74,"mm-yyyy"),$B$4:$B$70))/COUNT(IF((TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$74,"mm-yyyy"))*($B$4:$B$70<>""),1))

    ... confirm both formulas with Ctrl+Shift+Enter
    Last edited by pb71; 07-01-2010 at 05:59 PM.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Calculate Averages

    The Sumproduct is a clean way to get the Sumif result, without using an array formula
    =SUMPRODUCT((MONTH($A$4:$A$70)=MONTH(B73))*($B$4:$B$70))

    I am still working on the Countif part

  4. #4
    Forum Contributor
    Join Date
    05-16-2010
    Location
    UK
    MS-Off Ver
    2003 and 2007
    Posts
    252

    Re: Calculate Averages

    Dave,

    I think we had the same thought regarding SUMPRODUCT so I edited my post at about the same time you posted by the looks of it.

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Calculate Averages

    It should still be able to be done without Ctrl &Shift & Enter
    Last edited by davesexcel; 07-01-2010 at 06:11 PM.

  6. #6
    Forum Contributor
    Join Date
    05-16-2010
    Location
    UK
    MS-Off Ver
    2003 and 2007
    Posts
    252

    Re: Calculate Averages

    Do you mean something like:

    B77: =SUMPRODUCT((TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$73,"mm-yyyy"))*$B$4:$B$70)/SUMPRODUCT((TEXT($A$4:$A$70,"mm-yyyy")=TEXT($B$73,"mm-yyyy"))*($B$4:$B$70<>""))

    ... if averaging on the values in column B and not on the number of days in the month.
    Last edited by pb71; 07-01-2010 at 06:17 PM. Reason: Last comment deleted because incorrect as only 2 different months will ever be displayed

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Calculate Averages

    Yes! Here's mine using months instead of Text
    Please Login or Register  to view this content.
    Did you get
    10,500.19

    for May?

  8. #8
    Forum Contributor
    Join Date
    05-16-2010
    Location
    UK
    MS-Off Ver
    2003 and 2007
    Posts
    252

    Re: Calculate Averages

    I did indeed and using MONTH is neater.

    EDIT:

    ... as previously posted (but using MONTH instead):

    Just in case averaging over total days in the month:

    B77: =SUMPRODUCT((MONTH($A$4:$A$70)=MONTH(B73))*($B$4:$B$70))/SUMPRODUCT((MONTH($A$4:$A$70)=MONTH(B73))*1)
    Last edited by pb71; 07-01-2010 at 06:35 PM.

  9. #9
    Registered User
    Join Date
    03-02-2010
    Location
    Massachusetts, United States
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Calculate Averages

    Please disregard my previous post. I am all set. Thank you both for all your help! You guys rock~!

+ 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