+ Reply to Thread
Results 1 to 5 of 5

IF function and AVERAGE

  1. #1
    Registered User
    Join Date
    10-26-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    IF function and AVERAGE

    I am trying to teach myself Excel, but can's seem to get this formula to work.

    I have a list that looks like this:
    A B
    Row1 0 3
    Row2 2013 2
    Row3 0 1
    Row4 0 3
    Row5 2012 0

    I want to average the numbers in each column only if the number is <=3 and >=1 (so in column B average all the numbers except the 0 in row5). I also want colum A to return the number 0 or n/a if there are no numbers in that row <=3 and >=1.

    I tried =IF(AND(G3:G8<=3,G3:G8>=1),AVERAGE(G3:G8),"0") but this is returning the value error. Any suggestions of how to make this work?? I can attach an example spreadsheet if it would be helpful.

    Thanks!
    Last edited by laigUT; 10-26-2011 at 10:05 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,614

    Re: IF function and AVERAGE

    In XL2007 you can use AVERAGEIFS function:

    =AVERAGEIFS(G3:G8, G3:G8, ">=1", G3:G8, "<=3")

  3. #3
    Registered User
    Join Date
    10-26-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: IF function and AVERAGE

    That was what I was originally doing, but then I am getting an error when there are all zeros or other numbers (like 2011 or 2012) in the column. Is there a way to average if >=1 or <=3, but if this is not true then return a zero or n/a value?

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,614

    Re: IF function and AVERAGE

    you can count first is there any value in the range:

    =IF(COUNTIFS(G3:G8, ">1", G3:G8, "<=3")>0, AVERAGEIFS(G3:G8, G3:G8, ">=1", G3:G8, "<=3"), 0)

    Note: around numbers like 0 you don't need quotes like "0"
    Quotes are needed around text like "a"

  5. #5
    Registered User
    Join Date
    10-26-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: IF function and AVERAGE

    Perfect!! That worked. Thank you so much for your help!

+ 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