+ Reply to Thread
Results 1 to 15 of 15

Thread: Find a date and average corresponding data

  1. #1
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    51

    Find a date and average corresponding data

    Ok, Here's the setup:

    See the attachment

    I need a formula that will find a particular month in Column A and average the corresponding numbers in column B. And yes, the #N/A will be there too.
    I cannot use two cells with start and end dates.
    Attached Files Attached Files
    Last edited by jbmerrel; 12-15-2010 at 12:28 PM.

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Find a date and average corresponding data

    If you can't adjust the original errors then you can look at using the AVERAGEIFS function.

    Example

    D1: month of interest:
    1/1/2010
    
    E1:
    =AVERAGEIFS($B:$B,$B:$B,"<>#N/A",$A:$A,">"&$D1-DAY($D1),$A:$A,"<="&EOMONTH($D1,0))
    above will account for D1 not nec. being 1st of month.

    NOTE:
    AVERAGEIFS is not backwards compatible prior to XL2007 ... you would need to use an Array if that's a concern
    If you can revise the errors then a Pivot Table will do what you want for little / no effort.
    Last edited by DonkeyOte; 12-15-2010 at 09:26 AM.

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    MS 2007
    Posts
    5,372

    Re: Find a date and average corresponding data

    If you need it to be backwards compatable, this should work with your month spelled out in F1

    =SUM(IF(ISNUMBER($B$1:$B$53),IF(TEXT($A$1:$A$53,"mmmm")=$F$1,$B$1:$B$53)))

    As Donkey said, this needs to be entered as an array, CNTRL SHFT Enter instead of entering. If you do it right, you'll see brackets {} around the formula.
    ChemistB
    My 2¢

    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

  4. #4
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Find a date and average corresponding data

    I do need it to be backwards compatable. Sorry, I should have said that

  5. #5
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Find a date and average corresponding data

    Chemist B, You are getting close. I need it to average the numbers though, not just add them.

  6. #6
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Find a date and average corresponding data

    Change SUM to AVERAGE.

    (if you need to differentiate text & year then use mmyyyy as test)

  7. #7
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Find a date and average corresponding data

    THANKS!!!!!!!!!!!!!!!!!!

    Man, you guys are great!!!!!!!

  8. #8
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Find a date and average corresponding data

    One More Issue,

    If all of the data in Column B were #N/A for a particular month, then I need my Formula to output #N/A not Div/0. I am charting this data and charts do not like div/0.

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    MS 2007
    Posts
    5,372

    Re: Find a date and average corresponding data

    If a particular month is all #N/A, and you want to return #N/A, you need to do an error check like so

    =IF(ISERROR(AVERAGE(IF(ISNUMBER($B$1:$B$53),IF(TEXT($A$1:$A$53,"mmmm")=$F$1,$B$1:$B$53)))),NA(),AVER AGE(IF(ISNUMBER($B$1:$B$53),IF(TEXT($A$1:$A$53,"mmmm")=$F$1,$B$1:$B$53))))
    Does that work for you?
    ChemistB
    My 2¢

    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

  10. #10
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Find a date and average corresponding data

    One More Issue,

    If all the data in Column B for a particular month were #N/A, I would need the formula to output #N/A, not Div/0. I am charting this data and charts do not like DIV/0
    Last edited by jbmerrel; 12-15-2010 at 11:09 AM.

  11. #11
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Find a date and average corresponding data

    No that did not work, it just output "0". I entered it as an array and normally.

  12. #12
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Find a date and average corresponding data

    I would suggest you kill a few birds with one stone and use a construct along the lines of:

    =LOOKUP(9.99E+307,CHOOSE({1,2},"",AVERAGE(IF(etc...))))
    confirmed with CTRL + SHIFT + ENTER
    this way where the AVERAGE fails to return a Number an #N/A will result and you need only calculate the Array once.

    edit: note above modified from initial post - CHOOSE (and non-numeric first option) nec. for #N/A

  13. #13
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    MS 2007
    Posts
    5,372

    Re: Find a date and average corresponding data

    See attached.

    Did you forget to use CNTRL SHFT ENTER?
    Attached Files Attached Files
    ChemistB
    My 2¢

    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

  14. #14
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Find a date and average corresponding data

    I got it!!!!!

    You Guys are still Awesome!!!!!

    Thanks Again

  15. #15
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Find a date and average corresponding data

    Just for sake of clarity should this be reviewed by others latterly - using ChemistB's example of:

    =IF(ISERROR(AVERAGE(IF(ISNUMBER($B$1:$B$53),IF(TEXT($A$1:$A$53,"mmmm")=$F$2,$B$1:$B$53)))),NA(),AVERAGE(IF(ISNUMBER($B$1:$B$53),IF(TEXT($A$1:$A$53,"mmmm")=$F$2,$B$1:$B$53))))
    confirmed with CTRL + SHIFT + ENTER
    the alternative approach I proposed would look like:

    =LOOKUP(9.99E+307,CHOOSE({1,2},"",AVERAGE(IF(ISNUMBER($B$1:$B$53),IF(TEXT($A$1:$A$53,"mmmm")=$F$2,$B$1:$B$53)))))
    confirmed with CTRL + SHIFT + ENTER
    the advantage is that the Array itself is performed only once - though I would concede that on such a small data set this fact is largely irrelevant

+ 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.2.0