Ignoring NA Values in Sum

download Ignoring NA Values in Sum

of 2

Transcript of Ignoring NA Values in Sum

  • 8/14/2019 Ignoring NA Values in Sum

    1/2

    Ignoring N/A Values in a SumSummary: You can use some of Excels worksheet functions across a range or worksheets, butnot all of them. One that has problems with multi-sheet use is SUMIF, as discussed in this tip.There are ways to overcome the problems this can cause, but they involve rethinking some of

    your formulas. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, andExcel 2007.)

    Chris has a series of worksheets in a workbook, one for each month of the year. On a summaryworksheet he wants to sum the values in the same cell on each worksheet. Chris does this byusing a formula similar to the following:

    =SUM(January:December!B19)

    This works fine, except for those instances where one of the B19 cells in the range may containthe value #N/A. In that case, Chris gets #N/A in the result on the summary sheet, as well. WhatChris would like is to have the #N/A results ignored for the sum, as if the cells were blank.

    There are a couple of ways to approach this problem. Perhaps the best method is to look at the

    formula used in cell B19 of each month's worksheet. For instance, let's say that the formula oneach worksheet looked like this:

    =SUM(B1:B18)

    You could change the formulas on these individual worksheets so that they took the possibility of#N/A values into account. For instance, the following would work just fine at B19 on eachworksheet:

    =SUMIF(B1: B18,"#N/A")

    This causes the sum in cell B19, on each worksheet, to be based on all the non-N/A values in therange. Because of this, you might think you could do this on the summary sheet:

    =SUMIF(January:December!B19,"#N/A")

    This won't work, however, because the SUMIF function is not "three-dimensional" in nature; itcannot be used on a range of worksheets in the manner shown. It is for this reason that the bestsolution is to go back to the individual values, on each worksheet, that are being tallied on thesummary worksheet.

    If your formula on the individual month worksheets don't use the SUM function, it is obviouslynot as easy to change them to use SUMIF. In that case, you may want to "enclose" the existingformula in a check to see if the formula returns an error value. This technique is done this way:

    =IF(ISERROR(),0,)

    The IF function looks for a True/False value, which is returned by the ISERROR function. Thus,if the formula returns an error value (such as #N/A), then the IF function returns 0, otherwise it

    returns the result of the original formula. This approach checks for any error result; if you wouldprefer to have it only check for #N/A results and ignore them, then you can use the followingvariation:

    =IF(ISNA(),0,)

    There is a big difference between these IF-based approaches and using the SUMIF approachmentioned earlier in the tip. The SUMIF approach returns a sum for all non-N/A values in therange, but the IF-based approach returns a 0 for the entire sum if there are any #N/A values in the

    http://exceltips.vitalnews.com/Pages/T003156_Ignoring_NA_Values_in_a_Sum.htmlhttp://exceltips.vitalnews.com/Pages/T003156_Ignoring_NA_Values_in_a_Sum.htmlhttp://exceltips.vitalnews.com/Pages/T003156_Ignoring_NA_Values_in_a_Sum.htmlhttp://exceltips.vitalnews.com/Pages/T003156_Ignoring_NA_Values_in_a_Sum.htmlhttp://exceltips.vitalnews.com/Pages/T003156_Ignoring_NA_Values_in_a_Sum.htmlhttp://exceltips.vitalnews.com/Pages/T003156_Ignoring_NA_Values_in_a_Sum.htmlhttp://exceltips.vitalnews.com/Pages/T003156_Ignoring_NA_Values_in_a_Sum.htmlhttp://exceltips.vitalnews.com/Pages/T003156_Ignoring_NA_Values_in_a_Sum.html
  • 8/14/2019 Ignoring NA Values in Sum

    2/2

    range. This can obviously affect what shows up on your summary sheet, so you will need todetermine which approach is best suited to the data you are working with.