+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    07-02-2009
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003
    Posts
    4

    Sumproduct vs Countif

    I have a worksheet where I am trying to count the number of occurences of several text strings.

    For example:
    I'm trying to count how many times "paid in full" and "fully paid" occur in column A.

    I have two formulas, and both seem to work, but since I don't really understand either of them, I'm wondering which I should use and how I would adapt it to include additional text strings. (Like adding "paid" to the list)

    Here are my formuals (I didn't write either of them, another co-worker did)

    =(COUNTIF(A:A,"paid in full"))+(COUNTIF(A:A,"fully paid"))

    =SUMPRODUCT(--(A1:A50={"paid in full","fully paid"}))

    Also, if there is another and easier way to do what I'm trying to do, I'd love to know.

    Thanks for your help
    Last edited by jlm2; 07-02-2009 at 11:44 AM.

  2. #2
    Forum Moderator NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003, 2007, 2010
    Posts
    31,090

    Re: Sumproduct vs Countif

    Try:

    =SUMPRODUCT(--ISNUMBER(MATCH(A1:A50,{"paid in full","fully paid"},0)))

    and just add "paid" to the list between { } brackets
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Registered User
    Join Date
    07-02-2009
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Sumproduct vs Countif

    thanks for the quick reply!!

    but now I'm wondering how your formula is different than mine. Could you walk me through the differences, or maybe walk me through what your formula is doing.

    I have numerous other spreadsheets where I will be attempting something similar and would like to understand your logic.

    Also, I'm afraid some of the text strings have spaces occuring after the words, and the formula above doesn't capture them. How do i overcome this?

    Thanks again!

  4. #4
    Forum Moderator NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003, 2007, 2010
    Posts
    31,090

    Re: Sumproduct vs Countif

    Actually it's not really different.... yours should work..
    Mine checks to see that there are matches to the array and returns a position number if there is... then the position numbers get counted.

    To ignore extra spaces.. use Trim

    =SUMPRODUCT(--(TRIM(A1:A50)={"paid in full","fully paid"}))
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  5. #5
    Registered User
    Join Date
    07-02-2009
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Sumproduct vs Countif

    Thanks again.

    I don't mean to be a bother, but I really would like to fully understand the Sumproduct formula. I've read some stuff online but nothing really satifies my ignorance

    For instance, I have no idea what the two dashes in the beginning of the formula (right before TRIM in your latest formula.

    And finally, why is the Sumproduct formula better than the Countif? Or is it?

    Hope I haven't asked too many stupid questions.

  6. #6
    Forum Moderator NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003, 2007, 2010
    Posts
    31,090

    Re: Sumproduct vs Countif

    Have a look at this excellent article on Sumproduct:

    http://www.xldynamic.com/source/xld.SUMPRODUCT.html

    Countif is used for one condition and as you can tell, you need to make multiple Countifs linked together to get what you need.. and the Trim() function can't easily be added in the Countif function
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  7. #7
    Registered User
    Join Date
    07-02-2009
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Sumproduct vs Countif

    great link. Very helpful article.

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.2.0