+ Reply to Thread
Results 1 to 3 of 3

ignore null data in a sum

  1. #1
    Registered User
    Join Date
    07-09-2009
    Location
    Michigan, USA
    MS-Off Ver
    Excel 2003
    Posts
    11

    ignore null data in a sum

    It seems like there should be a simple solution for this problem, but I've been tinkering with it for awhile and can't come up with anything.

    I have two sheets in my workbook: one holds data (Sheet2), the other processes the data (Sheet1). Sheet2 has temperature data for each hour of every day during the year 1997 - about 9000 rows. Sheet1 averages the temperatures for each day together, and therefore has only 365 rows.

    However, some of the data is missing - null values are represented by the value -9999. Sheet1 only averages hourly data if there at least 22 non-null values. If there are fewer than 22 non-null values, a message is written into the cell to indicate such. (See day 119 on Sheet1 in the attached file for an example of this)

    I have the formula worked out to this point; however, I'd like to add in one more constraint: if a day has 2 or fewer null values, I still would like to average the data, but omit the null values in the average. (See day 118 on Sheet1 in the attached file for an example of this)

    My formula so far:
    Please Login or Register  to view this content.
    Any suggestions?
    Attached Files Attached Files
    Last edited by ruberg; 07-24-2009 at 03:48 PM. Reason: solved

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: ignore null data in a sum

    =IF(SUMPRODUCT(--(Sheet2!$B$1:$B$8780=B118),--(Sheet2!$C$1:$C$8780=-9999))<3,(SUMPRODUCT(--(Sheet2!$B$1:$B$8780=B118),--(Sheet2!$C$1:$C$8780<>-9999),--(Sheet2!$C$1:$C$8780)))/((SUMPRODUCT(--(Sheet2!$B$1:$B$8780=B118)))-SUMPRODUCT(--(Sheet2!$B$1:$B$8780=B118),--(Sheet2!$C$1:$C$8780=-9999))),0)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    07-09-2009
    Location
    Michigan, USA
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: ignore null data in a sum

    That works beautifully. Thank you!

+ 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