+ Reply to Thread
Results 1 to 9 of 9

Calculating Averages: Part Deux

  1. #1
    Registered User
    Join Date
    07-28-2006
    Posts
    28

    Cool Calculating Averages: Part Deux

    Is there a way to select a set of cells and determine the average for all cells that do not have 0 in them without a fat IF statement?
    A1: 5
    B1: 7
    C1: 0
    D1: 12
    E1: 3
    I'd like the average to be Sum(A1, C1, E1)/2 when the above example is true. If C1 changes to a number greater than 0, the average should be Sum(A1, C1, E1)/3.

  2. #2
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    Well an if statement makes it easier but

    sum(a1:e1)/countif(a1:e1,"<>0")

    regards

    Dav

  3. #3
    Registered User
    Join Date
    07-28-2006
    Posts
    28
    Thanks Dav but I wanted to sum specific cells and not the entire range. I'll probably go with an IF statement.

  4. #4
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    why If your exclusion is because the values are 0 if they are included the sum evaluates to the same number

    sumif(a1:e1,"<>0")/countif(a1:e1,"<>0")

    would be another solution, but is more complicated and will give you exactly the same answer.

    Or you need to restate the question

    Regards

    Dav

  5. #5
    Registered User
    Join Date
    07-28-2006
    Posts
    28

    Arrow

    The exclusion is simply that the cells I want to average are not adjacent. For example, in the attached image you will see totals for Shift 1, 2, and 3 and the last table is a combination of these three. I want the cells in the Combined Totals to be averages of the three shifts.

    Does this image and explanation help?
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-28-2006
    Posts
    28
    Sorry. The image didn't attach... Hope this one works.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    You do not have no 0's so

    sumif(b1:h1,">0")/countif(b1:h1,">0")

    Tell me if you have set the ranges correctly what is incorrect in the result, you have not been explict in the cells on the image you wish to be summed and averaged. If you are not you will not get a good answer, explain in english

    Regards

    Dav

  8. #8
    Registered User
    Join Date
    07-28-2006
    Posts
    28
    There is no data at present because the image I sent is from a blank template. I apologize if it aded to the confusion. Perhaps the attached will be more helpful.

    The "Combined Totals" table in this image includes the following rows:
    A167: Bottle Change
    A168: Cap Change
    A169: Bot/Cap Change
    A170: New Prod.
    A171: Same Product/Bottle/Cap
    I would like, for example, B167 to state "Look at cells B140, B149, B158 and give me an average of the sum of the cells that have a positive integer in them."

    Does that provide you with a clearer picture? Again, my apologies for not being more clear to start with.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    if the values are left blank rather than 0

    =IF(ISERROR(SUM(B140,B149,B158)/COUNT(B140,B149,B158)),"",SUM(B140,B149,B158)/COUNT(B140,B149,B158))

    I am working on if they are 0 maybe

    =IF(ISERROR(SUM(B140,B149,B158)/(COUNTIF(B140,">0")+COUNTIF(B149,">0")+COUNTIF(B158,">0"))),"",SUM(B140,B149,B158)/(COUNTIF(B140,">0")+COUNTIF(B149,">0")+COUNTIF(B158,">0")))

    regards

    Dav
    Last edited by Dav; 08-25-2006 at 08:46 PM.

+ 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