+ Reply to Thread
Results 1 to 4 of 4

Sumproduct with ISNA

  1. #1
    Forum Contributor
    Join Date
    02-10-2007
    MS-Off Ver
    Excel 2010
    Posts
    293

    Sumproduct with ISNA

    Hi All,

    I have this formula with conditional formatting, and it works as expected. =and(sumproduct(--(isna(b2:d2)))=0,or(b2>0,c2>0,d2>0)), it works when cells b2..d2 are blank.


    I am trying to understand this formula and was hoping it can be explained in plain english. I understand in general sumproduct takes two arrays, and if they are true then multiplies them as 1's and 0's and if = 1, then it takes values and adds them (hence sum of product).

    What I need help in is understanding the arrays in this formula and how it works with sumproduct.


    I understand that isna(b2:d2), if it is true then values in b2:d2 are not #N/A, however not clear how to interpret when = 0 , (isna(b2:d2)))=0

    So going back to formula,= and(sumproduct(--(isna(b2:d2)))=0,or(b2>0,c2>0,d2>0)),

    if the isna range (b2:d2) is true that it is not #N/A, because we are forcing to = 0, , then per sumproduct when value is true, it is considered a 1, now we multiply this with the 2nd half of sumproduct array, or(b2>0,c2>0,d2>0) , when any of these conditions are met i.e. b2>0, or c2>0, or d2 >0, and when these conditions are met it is also considered a 1. so 1 from first array x 1 from 2nd array= 1, so then make the cell the defined color per conditional formatting rule. is this correct interpretation?

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sumproduct with ISNA

    =AND(SUMPRODUCT(--(ISNA(B2:D2)))=0,OR(B2>0,C2>0,D2>0))

    The entire formula is testing for 2 conditions:

    Condition1: SUMPRODUCT(--(ISNA(B2:D2)))=0

    Condition2: OR(B2>0,C2>0,D2>0)

    Both conditions MUST evaluate to TRUE for the formatting to be applied.

    The SUMPRODUCT function is testing for the presence of the #N/A error value.

    You can also write it like this and save a couple of keystrokes:

    SUMPRODUCT(--ISNA(B2:D2))=0

    So, if there are no #N/A errors AND any cell contains a value greater than 0 then the format will be applied.

    =AND(TRUE,TRUE) = format applied

    Here's something you may not be aware of...

    In Excel TEXT has a higher value than any number.

    For example: ="A">100 = TRUE

    So, if any cell contains a TEXT value then: OR(B2>0,C2>0,D2>0) = TRUE

    That could lead to a "false positive" but if there will never be text values in the range then you don't have to worry about it.
    Last edited by Tony Valko; 01-15-2017 at 11:16 PM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Contributor
    Join Date
    02-10-2007
    MS-Off Ver
    Excel 2010
    Posts
    293

    Re: Sumproduct with ISNA

    Thanks Tom for taking the time to explain it. Appreciate it. Beginning to make sense.

    A follow up question:

    The SUMPRODUCT function is testing for the presence of the #N/A error value.


    SUMPRODUCT(--ISNA(B2:D2))=0 or SUMPRODUCT(--(ISNA(B2:D2)))=0

    What I am baffled by is it the formula only works if the cells i.e. b2 or c2 or d2 If there is a number then it works as should. If those cells were blank or empty, the formula fails, unless I press "clear content" then it works as expected, and no hidden characters either.

    If I want to have it where cell contains # NA instead of a blank, then I assume it is SUMPRODUCT(--ISNA(B2:D2))<>"#N/A" correct?

    Lastly im not clear as to -ISNA(B2:D2))=0, this is looking in cells b2..d2, and it's saying, if its true the cells do not contain #n/a then make that cell = 0, correct?

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sumproduct with ISNA

    Quote Originally Posted by VegasL View Post
    The SUMPRODUCT function is testing for the presence of the #N/A error value.

    SUMPRODUCT(--ISNA(B2:D2))=0 or SUMPRODUCT(--(ISNA(B2:D2)))=0

    What I am baffled by is it the formula only works if the cells i.e. b2 or c2 or d2 If there is a number then it works as should. If those cells were blank or empty, the formula fails, unless I press "clear content" then it works as expected, and no hidden characters either.
    What formula fails?

    If the cells are blank or empty then:

    SUMPRODUCT(--ISNA(B2:D2))=0 = TRUE

    But:

    OR(B2>0,C2>0,D2>0) = FALSE

    So the ENTIRE formula:

    =AND(SUMPRODUCT(--(ISNA(B2:D2)))=0,OR(B2>0,C2>0,D2>0)) = FALSE

    Since BOTH conditional tests are not TRUE.

    Perhaps you should explain what you're trying to do exactly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. If(ISNA?
    By hendersonp in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-29-2008, 03:02 AM
  2. [SOLVED] ISNA
    By Bob Phillips in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 09-06-2005, 06:05 PM
  3. [SOLVED] ISNA
    By Bob Phillips in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-06-2005, 11:05 AM
  4. [SOLVED] ISNA
    By Bob Phillips in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-06-2005, 07:05 AM
  5. [SOLVED] ISNA
    By Bob Phillips in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-06-2005, 04:05 AM
  6. [SOLVED] ISNA
    By Lomax in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  7. ISNA
    By Lomax in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  8. ISNA
    By Lomax in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM

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