+ Reply to Thread
Results 1 to 14 of 14

Count the number of instances where multiple criteria match

  1. #1
    Registered User
    Join Date
    12-08-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Count the number of instances where multiple criteria match

    I am having a similar problem to others in the subforum. I am trying to count the number of instances where TRUE shows up in the 'Buy' column (AF in the formula) and there is a corresponding number on the same line in the 'Shipped 2010' (AP) column.
    I have tried =SUMPRODUCT(--(AF4:AF4270="TRUE"),(AP4:AP270>0)) and =SUMPRODUCT(--(AF4:AF4270="TRUE")*(AP4:AP270>0)) but getting the #value sign. I am not sure what I am doing wrong. HELP!

    Buy Shipped 2010
    FALSE 1
    FALSE -
    FALSE -
    FALSE 12
    TRUE 6
    Last edited by kurt.l; 12-10-2012 at 12:12 PM. Reason: Change title

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Sumproduct

    Maybe?

    =SUMPRODUCT((AF4:AF4270="TRUE")*(AP4:AP4270>0))
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Sumproduct

    Try this:

    =SUMPRODUCT((AF4:AF4270=TRUE)*(AP4:AP4270>0))

    - Moo

    * Looks like Fotis punched it in before I could... but I thought I would also add the difference between TRUE (a formula result) and "TRUE" (a text string).

  4. #4
    Registered User
    Join Date
    12-08-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Sumproduct

    Thanks for the fast response.

    I get 0 as the answer in that case. Column AP is pulling in values using a vlookup, which I thought perhaps could be the issue, but I tried copying and pasting values, but I still get 0.

  5. #5
    Registered User
    Join Date
    12-08-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Sumproduct

    Thanks Moo and Fotis, that did it.

    It was 'true', it was looking for the formula result, not a text string.

  6. #6
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Sumproduct

    Glad you got it figured out.

    - Moo
    Last edited by Moo the Dog; 12-08-2012 at 04:58 PM. Reason: Thanks for the rep. :)

  7. #7
    Registered User
    Join Date
    12-08-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Sumproduct

    Well.....almost.
    Strange thing is I did a =COUNTIF(AP4:AP4270,">0") which gave me 2335,but when I add the results of =SUMPRODUCT((AF4:AF4270=TRUE)*(AP4:AP4270>0)) and =SUMPRODUCT((AF4:AF4270=FALSE)*(AP4:AP4270>0)), which should give me the total of the parts, both purchased (TRUE) and manufactured (FALSE), I get a total of 2309 - a difference of 26.

    Column AF has either a TRUE or FALSE (which totals 4267) and the sum of =COUNTIF(AP4:AP4270,"=0") and =COUNTIF(AP4:AP4270,">0") = 4267, so I am stumped why I am out 26.

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Count the number of instances where multiple criteria match

    It might help if you posted your workbook as a sample to work from.

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    HTH
    Regards, Jeff

  9. #9
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Count the number of instances where multiple criteria match

    Strange thing is I did a =COUNTIF(AP4:AP4270,">0") which gave me 2335,but when I add the results of =SUMPRODUCT((AF4:AF4270=TRUE)*(AP4:AP4270>0)) and =SUMPRODUCT((AF4:AF4270=FALSE)*(AP4:AP4270>0)), which should give me the total of the parts, both purchased (TRUE) and manufactured (FALSE), I get a total of 2309 - a difference of 26.
    What that seems to tell me is that there are 26 cells in column AF that are neither TRUE or FALSE. Or, there are 26 cells where AF = True/False, but AP <= 0

    - Moo
    Last edited by Moo the Dog; 12-08-2012 at 06:33 PM.

  10. #10
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Count the number of instances where multiple criteria match

    As Jeffrey stated above, if you can upload your workbook (remove any sensitive data first), we may be able to figure out the issue. Without the actual data, it is pretty hard to diagnose.

    - Moo

  11. #11
    Registered User
    Join Date
    12-08-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Count the number of instances where multiple criteria match

    I have attached a sample of the file.

    Thanks for taking the time to look at it.
    Attached Files Attached Files

  12. #12
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Count the number of instances where multiple criteria match

    Your formulas in L604, M604 and N604 are incorrrect. They look at the range L5:L600, M5:M600, and N5:N600, when they should be looking at the range of L4:L599, M4:M599, N4:N599.

    You must have just copied the formulas from the row above and pasted into row 604, which would account for the changed ranges - as well as the differing totals.

    - Moo

  13. #13
    Registered User
    Join Date
    12-08-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Count the number of instances where multiple criteria match

    Thanks Moo, looked at the formulae so many times, yet I missed it repeatedly.

    Thanks again for all your help.

  14. #14
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Count the number of instances where multiple criteria match

    You're quite welcome. Glad to help.

    - Moo

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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