+ Reply to Thread
Results 1 to 7 of 7

Countifs array results not as expected, can anyone see why?

Hybrid View

jason.b75 Countifs array results not as... 07-15-2012, 09:02 AM
Palmetto Re: Countifs array results... 07-15-2012, 09:13 AM
Spencer101 Re: Countifs array results... 07-15-2012, 09:19 AM
jason.b75 Re: Countifs array results... 07-15-2012, 09:40 AM
icestationzbra Re: Countifs array results... 07-15-2012, 11:06 AM
jason.b75 Re: Countifs array results... 07-15-2012, 01:39 PM
icestationzbra Re: Countifs array results... 07-15-2012, 01:45 PM
  1. #1
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Countifs array results not as expected, can anyone see why?

    This could be a known bug or simply me suffering from brainfreeze searching google came up with nothing relevant.

    A simplified scenario that reproduces the problem, first copy the table below into A1:B4

    A 1
    A 2
    B 1
    B 3

    Enter the formula =SUMPRODUCT(COUNTIFS($A$1:$A$4,"A",$B$1:$B$4,$B$1:$B$4))

    Now go to formula evaluation and click evaluate once, the result, SUMPRODUCT({1,1,1,0})

    Any thoughts why the third row is being counted when it doesn't meet the criteria in column A?

    Thanks in advance.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Countifs array results not as expected, can anyone see why?

    You don't need SUMPRODUCT, just use the COUNTIFS function.
    Your last criteria in the COUNTIFS argument makes no sense to me. Explain your criteria for counting.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Valued Forum Contributor
    Join Date
    04-03-2012
    Location
    East Sussex, UK
    MS-Off Ver
    Excel 2003:2010
    Posts
    893

    Re: Countifs array results not as expected, can anyone see why?

    I know you're demonstrating something you see that's not working, but an idea of what you're actually trying to do with this formula in the main workbook would be a great help.
    If I've been of help, please hit the star

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Countifs array results not as expected, can anyone see why?

    This was something I found by accident when a solution I provided in another thread failed.

    The purpose of the formula is for counting unique records, hence the final criteria that caused confusion, the full formula:-

    {=SUM(IFERROR(1/COUNTIFS($A$1:$A$4,"A",$B$1:$B$4,$B$1:$B$4),))}

    Test file attached that shows several configurations of values with actual and expected results.Countifs calamity test.xlsx

    Hopefully makes more sense this time.

    edit:- the other thread has been solved with a frequency array, I'm just trying to understand why this doesn't work as expected.

  5. #5
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Countifs array results not as expected, can anyone see why?

    here is how i would solve it:

    =SUMPRODUCT(($A$1:$A$4="A")*(1/COUNTIFS($A$1:$A$4,$A$1:$A$4,$B$1:$B$4,$B$1:$B$4)))
    {=SUM(IFERROR(1/COUNTIFS(A$1:A$4,A$1:A$4,B$1:B$4,B$1:B$4),)*(A$1:A$4="A")})
    the condition needs to be outside of COUNTIF(S). apparently, using the "A" condition within the COUNTIF(S) while it is in an array-type formula, elicits a "union" effect, which is visible only if the values in column B are repeating, else, it is business as usual.
    Last edited by icestationzbra; 07-15-2012 at 11:28 AM. Reason: info
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  6. #6
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Countifs array results not as expected, can anyone see why?

    Quote Originally Posted by icestationzbra View Post
    the condition needs to be outside of COUNTIF(S). apparently, using the "A" condition within the COUNTIF(S) while it is in an array-type formula, elicits a "union" effect, which is visible only if the values in column B are repeating, else, it is business as usual.
    Thanks for taking the time to look at this and providing a good theory on the cause, I was getting the feeling that I was missing something obvious, but it would appear to be a bit of a glitch with the function

    After looking at your soulutions I tried something else that also works,

    {=SUM(IFERROR(1/COUNTIFS(A$1:A$4,A$1:A$4,A$1:A$4,"A",B$1:B$4,B$1:B$4),))}
    The thought behind these methods was looking for alternatives to frequency (I can never seem to get the arrays right), but calculation is a bit clunky, think I just need to spend a bit more time trying to get to grips with the tried and tested methods.
    Last edited by jason.b75; 07-15-2012 at 01:46 PM.

  7. #7
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Countifs array results not as expected, can anyone see why?

    i would go only so far to assume that the array-type envelope induces that behaviour, that which is not a glitch in the stand-alone function.
    Last edited by icestationzbra; 07-15-2012 at 01:49 PM.

+ 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