+ Reply to Thread
Results 1 to 9 of 9

Counting the number of entries with 2 criteria

  1. #1
    Registered User
    Join Date
    09-08-2008
    Location
    London
    Posts
    40

    Counting the number of entries with 2 criteria

    Hi,

    I want to pick out the number of "Current" employees for Group A and the number of "Current" employees from Group B. Can anyone suggest a formula which would do this?

    I attach an example of what I use and how I want the results to appear.


    Many thanks in advance for any help with this.
    McQLon
    Attached Files Attached Files

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Counting the number of entries with 2 criteria

    Perhaps:

    Please Login or Register  to view this content.
    Though it would be better to place:

    Please Login or Register  to view this content.
    THen you can use a SUMIF (more efficient)

    Please Login or Register  to view this content.

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting the number of entries with 2 criteria

    Try:

    =SUMPRODUCT(--($B$10:$B$22=$B4),--($C$10:$C$22="Current"))

    copied down to B5
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,443
    Hi,

    In C4 and C5 ,

    =SUMPRODUCT(($B$10:$B$22=B4)*($C$10:$C$22="Current"))
    =SUMPRODUCT(($B$10:$B$22=B5)*($C$10:$C$22="Current"))
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  5. #5
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,443

    Re: Counting the number of entries with 2 criteria

    @DonkeyOte and NVBC,

    We all quite often answer threads requiring a SUMPRODUCT answer. I'm just curious is there any benifit in using =SUMPRODUCT(--(array1),--(array2)) over =SUMPRODUCT((array1)*(array2)) ?

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Counting the number of entries with 2 criteria

    There are a few reasons IMO for using double unary over multiplication:

    a) -- is regarded as quicker (slightly)
    (some argue for single unary approach but that brings with it other risks)

    b) -- method allows for non-numerics in summation range (if used)

    consider

    A1 & A2 = "a"
    B1 & B2 = "b" & 10 respectively

    =SUMPRODUCT((A1:A2="a")*(B1:B2)) --> #VALUE!
    =SUMPRODUCT(--(A1:A2="a"),B1:B2) --> 10

    If you've not already have a read of Bob's page: http://www.xldynamic.com/source/xld.SUMPRODUCT.html

    I have other links on the topic of coercion if interested.

  7. #7
    Registered User
    Join Date
    09-08-2008
    Location
    London
    Posts
    40

    Re: Counting the number of entries with 2 criteria

    It's working fine with those formulas! Thanks!

    In the end I named the ranges and used Countif.

    Thanks again!

  8. #8
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,443

    Re: Counting the number of entries with 2 criteria

    I see, thanks.

    In my finite world the speed of the function isn't going to count for much, so I think that the "non numerics in a summation range" is probably the best arguement for using double unary. Thanks for the link, and the explaination.

    Dave

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Counting the number of entries with 2 criteria

    It's interesting that here at ExcelForum.com the more common approach is Sumproduct by * whereas over at MrExcel.com the double unary approach is the norm... in truth it's a case of "horses for courses" but in the majority of cases I honestly believe double unary to be the better more flexible of the approaches.

    HOWEVER...

    The double unary approach IS restricted insofar as each range must be of equal dimension...

    Assume A1:A2 holds criteria and B1:Z2 hold numerical value

    =SUMPRODUCT(--(A1:A2="a"),B1:Z2)

    will NOT work... you must use:

    =SUMPRODUCT((A1:A2="a")*(B1:Z2))

    However, if you had criteria in A1:B2 and values in C1:D2 you could use --

    =SUMPRODUCT(--(A1:B2="a"),C1:D2)

    because both ranges are 2 x 2

+ 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