+ Reply to Thread
Results 1 to 6 of 6

Array average excluding zeros

  1. #1
    Forum Contributor
    Join Date
    03-09-2009
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007
    Posts
    128

    Array average excluding zeros

    Hi,

    I'm using the Average array formula to calculate average for certain values with specific months and year

    =AVERAGE(IF(YEAR($C$4:$C$14)=Z9;IF(MONTH($C$4:$C$14)=AA9;$F$4:$F$14;""));"")

    The two first IF just checks whether it is the right month and year. The last bit gets the numbers, that is going to make up the average. However my problem it seems is that the average also includes Not true = "", when calculating the average.

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Array average excluding zeros

    Try
    Please Login or Register  to view this content.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Array average excluding zeros

    You can add an ISNUMBER test to your existing Array

    Please Login or Register  to view this content.
    However, given the analysis is monthly and use of XL2007 you could just use:

    Please Login or Register  to view this content.
    which would be more efficient

  4. #4
    Forum Contributor
    Join Date
    03-09-2009
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Array average excluding zeros

    arthurbr:

    Thanks, but something is not working with your code

    =SUMPRODUCT((YEAR($C$4:$C$14)=Z9)*(MONTH($C$4:$C$14)=AA9)*($F$4:$F$14<>""))/COUNTIF($F$4:$F$14;"<>0")

    $F$4:$F$14 if this is 0 then is affects the result, I need to exclude zeros so they do not affect the result

  5. #5
    Forum Contributor
    Join Date
    03-09-2009
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Array average excluding zeros

    DonkeyOte:

    Thanks your first example worked fine Only problem is that it gets a divided by zero error, if no data is available for that month/year... how do I fix taht?

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Array average excluding zeros

    If you're using XL2007+ you should use the AVERAGEIFS approach and add an IFERROR handler.

    If you're using with versions prior to XL2007 then the most appropriate handler will depend on the values being returned - if for ex. you know the Average (where an Avg exist) will always exceed 0 you could avoid double evaluation with:

    Please Login or Register  to view this content.
    and then apply a Custom Format (if nec.) to mask the 0 output as and when it occurs.
    Generally speaking it's always a good idea to avoid double evaluation of "expensive" formulae

+ 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