+ Reply to Thread
Results 1 to 20 of 20

how to do a count

  1. #1
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    how to do a count

    Hello. I have values in Column D that I would like to count. I want to count all of the values of 2, BUT do not include the 2's for the value in column F (same row) is less than the value in column E (same row). How can I do this? Thanks.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,457

    Re: how to do a count

    Untested:

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    Re: how to do a count

    Thanks. I'll try this out. Is there a way to do it with countifs?

  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: how to do a count

    Quote Originally Posted by ammartino44 View Post
    Is there a way to do it with countifs?
    Unfortunately, no.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Thumbs up Re: how to do a count

    Yeah it is possible with countifs..
    Give it a try.. (Amazing use of countifs)
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    check the attached file..
    Attached Files Attached Files
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,457

    Re: how to do a count

    @VG: I'm not sure that's what the OP meant. But 10/10 for effort.

    I think, in this instance, the SUMPRODUCT is making the equivalent of an Array Function. So, maybe you could array enter the COUNTIFS without the SUMPRODUCT.

  7. #7
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: how to do a count

    Thanks for appreciation..TMS..
    I means a lot to me..

    However Entering countifs using array will return the array of 1s and 0s..
    So we have to use Sum with array or Sumproduct to sum the array...

    I hope this helps..

    A reputation point will encourage me TMS..

    Thanks in advance..

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,457

    Re: how to do a count

    Not sure of the value of using two functions where one will do but, as you say, amazing use of COUNTIFS.

  9. #9
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: how to do a count

    Difference is in the Array Multiplication and Countifs
    I guess the countifs version will be more fast with bigger ranges...
    However you can test the speed.. using following link..
    http://msdn.microsoft.com/en-us/libr...ffice.14).aspx
    Use the code in the link to test the speed over bigger ranges to test the speed..
    and declare the winner..
    though I haven't tested it yet..

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,457

    Re: how to do a count

    Thanks, I'll have a play with that at some point.

    However, for the purpose of this thread, I'm prepared to take the simplistic view that, if SUMPRODUCT provides a result on its own, then it is likely that using SUMPRODUCT with COUNTIFS will take longer.

    I think we need to wait for some input and.or feedback from the OP.

    Regards, TMS

  11. #11
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: how to do a count

    There is one more point of view...
    The FORMULA AUDITING STEPS..
    Just count the steps for both the formulas .. and which would have least steps will be the winner (I suppose)

    Edit:
    Countifs do it in 3-4 steps
    Sumproduct with array multiplication will do it in 5-6 steps..
    Last edited by Vikas_Gautam; 09-16-2014 at 09:06 AM.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,457

    Re: how to do a count

    @VG: my original formula was marked as "untested". That's because I had no data to test it on and, as far as I am aware, I still don't. I know that you provided a workbook but that's your interpretation (which may well be correct). However, I've put my formula into that and compared it to yours.

    Using the Range Timer code, it appears my formula is the faster of the two. But, using Evaluate Formula, there are less steps in yours, which I guess is a good thing.

    All that said, I'm going to draw a line now as the OP doesn't seem to be showing any interest in the answers or the discussion.

    Regards, TMS

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

    Re: how to do a count

    Quote Originally Posted by Vikas_Gautam View Post
    Yeah it is possible with countifs..
    Not without passing the COUNTIFS to a function that can handle arrays. It is not possible using just COUNTIFS.

    Using COUNTIFS as you have is very inefficient as I've noted in other threads.

  14. #14
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: how to do a count

    Thanks TMS and Tony Volko..
    Good discussion ends with a nice conclusions....

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

    Re: how to do a count

    Quote Originally Posted by Tony Valko View Post

    Using COUNTIFS as you have is very inefficient...
    Let me rephrase that.

    Using COUNTIFS in that manner is slower to calculate. The larger the range the slower it is to calculate.

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

    Re: how to do a count

    Quote Originally Posted by TMS View Post
    @VG: my original formula was marked as "untested". That's because I had no data to test it on and, as far as I am aware, I still don't. I know that you provided a workbook but that's your interpretation (which may well be correct). However, I've put my formula into that and compared it to yours.

    Using the Range Timer code, it appears my formula is the faster of the two. But, using Evaluate Formula, there are less steps in yours, which I guess is a good thing.

    All that said, I'm going to draw a line now as the OP doesn't seem to be showing any interest in the answers or the discussion.

    Regards, TMS
    Related...

    https://www.excelforum.com/showthread.php?t=1035202

  17. #17
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: how to do a count

    Yeah.. Tony I got it..
    you are absolutely correct..
    I will take care in future while making formulas...

    Can you tell me which is faster of the two...
    1. NESTED IFS or
    2. ARRAY MULTIPLICATION... ?

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

    Re: how to do a count

    In Excel 2002 I tested these array formulas on various sized ranges:

    Formula1:

    =INDEX(D:D,MATCH(1,(Range1=F2)*(Range2=G2)*(Range3=H2),0))

    Formula2:

    =INDEX(D:D,MATCH(1,IF(Range1=F2,IF(Range2=G2,IF(Range3=H2,1))),0))

    Here are the results I got:

    Data Range
    F
    G
    H
    I
    J
    K
    L
    M
    4
    Formula1
    Rows
    Test1
    Test2
    Test3
    Test4
    Test5
    Average
    5
    100
    0.00025
    0.00026
    0.00026
    0.00026
    0.00026
    0.000258
    6
    1000
    0.00134
    0.00133
    0.00133
    0.00133
    0.00134
    0.001334
    7
    10000
    0.01151
    0.01141
    0.01141
    0.01145
    0.01141
    0.011438
    8
    50000
    0.03552
    0.04889
    0.04880
    0.03633
    0.04233
    0.042374
    9
    10
    Formula2
    Rows
    Test1
    Test2
    Test3
    Test4
    Test5
    Average
    11
    100
    0.00027
    0.00027
    0.00028
    0.00027
    0.00027
    0.000272
    12
    1000
    0.00139
    0.00139
    0.00145
    0.00149
    0.00139
    0.001422
    13
    10000
    0.01191
    0.01193
    0.01204
    0.01188
    0.01187
    0.011926
    14
    50000
    0.04399
    0.04835
    0.04158
    0.04417
    0.05409
    0.046436


    In this application array multiplication was slightly faster than nested IFs.

  19. #19
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: how to do a count

    Thanks for the results Tony..
    Now I will suggest Array multiplication.. as possible as I can..

    Thank for this beautiful presentation as well..

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

    Re: how to do a count

    You're welcome!

+ 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. [SOLVED] Sort and Count Unique List Across Multiple Columns - Student Count
    By BuntyMac in forum Excel Formulas & Functions
    Replies: 22
    Last Post: 08-17-2014, 07:00 AM
  2. Range.columns.count property returns wrong count after union operation
    By gopinan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-13-2008, 04:48 AM
  3. [SOLVED] Count Intervals of Filtered TEXT values in Column and Return Count across a Row
    By Domenic in forum Excel Formulas & Functions
    Replies: 46
    Last Post: 09-06-2005, 07:05 PM
  4. Replies: 27
    Last Post: 09-06-2005, 04:05 AM
  5. [SOLVED] Count Intervals of Filtered TEXT values in Column and Return Count across a Row
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10: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