+ Reply to Thread
Results 1 to 10 of 10

Array formula: count non-zero values in two columns

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    6

    Question Array formula: count non-zero values in two columns

    Hi,

    I have two columns that each have numbers and blank cells - column H and column I - and x number of rows. I currently have the array formula (included in another sheet) below to count how many numbers in the first column (column H) are greater than the corresponding numbers in the second column (column I). An example of a result of this formula is that there are 60 instances where the number in column H is greater than the corresponding number in column I.
    The only problem is that this array formula also counts the blanks/zero values.

    {=(SUM((Sheet1!$I17:$I451<Sheet1!$H17:$H451)*1))}

    How may I alter this formula so that it counts the number of numbers in column H that are greater than the numbers in column I, ignoring all blanks? I am using Excel 2010.
    (Apologies, I'm very new to array formulas, and endless research online hasn't helped.)

    Thanks in advance for your help!

    RN

  2. #2
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: Array formula: count non-zero values in two columns

    Hi RN, try this array formula...

    {=SUM(($I$17:$I$451<$H$17:$H$451)*(NOT(ISBLANK($I$17:$I$451))))}

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

    Re: Array formula: count non-zero values in two columns

    One way:

    =SUMPRODUCT(--(Sheet1!I17:I451<>""),--(Sheet1!H17:H451>Sheet1!I17:I451))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    05-07-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Array formula: count non-zero values in two columns

    Hi djapigo,

    I think it works...! I've slightly adjusted it, however, so that the not isblank extends to both columns. It seems to work (having done a manual check), but let me know if the below looks wrong.

    {=SUM((Sheet1!$I$17:$I$451<Sheet1!$H$17:$H$451)*(NOT(ISBLANK(Sheet1!$I$17:$I$451))*(NOT(ISBLANK(Sheet1!$H$17:$H$451)))))}

    Thanks very much for your help!

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

    Re: Array formula: count non-zero values in two columns

    Are there any negative numbers in column I?

    If not then you don't need to test for:

    NOT(ISBLANK(Sheet1!$H$17:$H$451))

    BTW, that can be reduced to:

    (Sheet1!$H$17:$H$451<>"")

  6. #6
    Registered User
    Join Date
    05-07-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Array formula: count non-zero values in two columns

    Hi Tony,

    FYI, there are numbers in column H.

    The reduction you've suggested works just as well as the previous suggestions.

    Final result is (if my understanding is correct): {=SUM((Sheet1!$J$17:$J$451<Sheet1!$I$17:$I$451)*(Sheet1!$J$17:$J$451<>"")*(Sheet1!$I$17:$I$451<>""))}

    Thanks!

  7. #7
    Registered User
    Join Date
    05-07-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Array formula: count non-zero values in two columns

    Sorry - I meant to say there are NEGATIVE numbers in column H.

  8. #8
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: Array formula: count non-zero values in two columns

    Nice work, Roxana... I'm glad it worked...

    Nice advice, Tony...

  9. #9
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: Array formula: count non-zero values in two columns

    Nice work, Roxana... I'm glad it worked...

    Nice advice, Tony...

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

    Re: Array formula: count non-zero values in two columns

    Good deal. Thanks for the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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