Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 07-02-2009, 09:37 AM
jlm2 jlm2 is offline
Registered User
 
Join Date: 02 Jul 2009
Location: Portland, OR
MS Office Version:Excel 2003
Posts: 4
jlm2 is becoming part of the community
Sumproduct vs Countif

Please Register to Remove these Ads

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 10:44 AM.
Reply With Quote
  #2  
Old 07-02-2009, 09:39 AM
NBVC's Avatar
NBVC NBVC is online now
Forum Guru
 
Join Date: 06 Dec 2006
Location: Mississauga, CANADA
MS Office Version:2003 & 2007
Posts: 18,512
NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future
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
__________________
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 my reputation by clicking the icon next to the Post # in the bar above my avatar (picture) in this post.

Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Reply With Quote
  #3  
Old 07-02-2009, 09:44 AM
jlm2 jlm2 is offline
Registered User
 
Join Date: 02 Jul 2009
Location: Portland, OR
MS Office Version:Excel 2003
Posts: 4
jlm2 is becoming part of the community
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!
Reply With Quote
  #4  
Old 07-02-2009, 09:58 AM
NBVC's Avatar
NBVC NBVC is online now
Forum Guru
 
Join Date: 06 Dec 2006
Location: Mississauga, CANADA
MS Office Version:2003 & 2007
Posts: 18,512
NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future
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"}))
__________________
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 my reputation by clicking the icon next to the Post # in the bar above my avatar (picture) in this post.

Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Reply With Quote
  #5  
Old 07-02-2009, 10:04 AM
jlm2 jlm2 is offline
Registered User
 
Join Date: 02 Jul 2009
Location: Portland, OR
MS Office Version:Excel 2003
Posts: 4
jlm2 is becoming part of the community
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.
Reply With Quote
  #6  
Old 07-02-2009, 10:09 AM
NBVC's Avatar
NBVC NBVC is online now
Forum Guru
 
Join Date: 06 Dec 2006
Location: Mississauga, CANADA
MS Office Version:2003 & 2007
Posts: 18,512
NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future
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
__________________
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 my reputation by clicking the icon next to the Post # in the bar above my avatar (picture) in this post.

Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Reply With Quote
  #7  
Old 07-02-2009, 10:44 AM
jlm2 jlm2 is offline
Registered User
 
Join Date: 02 Jul 2009
Location: Portland, OR
MS Office Version:Excel 2003
Posts: 4
jlm2 is becoming part of the community
Re: Sumproduct vs Countif

great link. Very helpful article.
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump