+ Reply to Thread
Results 1 to 4 of 4

Array formula

  1. #1
    Registered User
    Join Date
    07-02-2010
    Location
    belgium
    MS-Off Ver
    Excel 2003
    Posts
    2

    Array formula

    Hi,

    Look at this little table:

    a 1
    z 2
    a 3
    r 4

    I want to count the number of occurences of "a". I know there is a easier way to do that using COUNTIF, but i'm experimenting with array formula and i did it in two ways:

    COUNT((L7:L10="a")*(M7:M10)) -> this gives 4 !?!
    COUNT(IF(L7:L10="a";M7:M10)) -> this gives 2

    I thought that both formulas were the same (i did the same with SUM and both formulas produce 4). So why does the first formula produce a wrong result?

    Thanks
    beamon

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: problem with array formula

    Try this:

    =COUNT(IF(L7:L10="a";ROW(L7:L10)))

    Thid doesn't depend of second column. It just calculate number of a in first column.

    Your approach might give you different results depending of data in M column

    Problem with first formula is because it counts zero's in product as numbers.

    Evaluate formula:

    =COUNT((L7:L10="a")*(M7:M10))
    =COUNT(({TRUE;FALSE;TRUE;FALSE}*(M7:M10))
    =COUNT(({TRUE;FALSE;TRUE;FALSE}*{1;2;3;4})
    =COUNT({1;0;3;0})
    =4

    while second formula give this:

    =COUNT(IF(L7:L10="a";M7:M10))
    =COUNT(IF({TRUE;FALSE;TRUE;FALSE};M7:M10))
    =COUNT({1;FALSE;3;FALSE})
    =2
    Last edited by zbor; 07-02-2010 at 05:03 AM.

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: problem with array formula

    Or this, non-array:

    =SUMPRODUCT(--($L$7:$L$10="a"))

  4. #4
    Registered User
    Join Date
    07-02-2010
    Location
    belgium
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: problem with array formula

    Thanks for replying

+ 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