+ Reply to Thread
Results 1 to 9 of 9

How to count number of occurrences in a table if certain criteria are met.

  1. #1
    Registered User
    Join Date
    03-30-2014
    Location
    Australia
    MS-Off Ver
    Excel 2003 & 10
    Posts
    30

    How to count number of occurrences in a table if certain criteria are met.

    Hi there,

    I am trying to write a formula to populate a table on sheet 2. Basically I need to count the number of deliveries, pickups or on holds for that meet certain criteria ie on June 12 product A had 1 old customer order & then picked up the product, therefore the cell would populate 1. I have complete data for June 12 as an example.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: How to count number of occurrences in a table if certain criteria are met.

    Hello,

    in cell D3 use

    =SUMPRODUCT((Sheet1!$C$2:$E$9=Sheet2!G$2)*(Sheet1!$A$2:$A$9=Sheet2!$B3)*(Sheet1!$B$2:$B$9=Sheet2!$C3)*(Sheet1!$C$1:$E$1=Sheet2!$A3))

    copy across and down.

    Your dates show as month/year but the underlying values are either day 1 or day 30. You need to straighten this out and ensure that the date values are identical on both sheets.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: How to count number of occurrences in a table if certain criteria are met.

    @ teylyn, you reference Sheet2!G$2, but that cell is empty. Is that to enter a variable?

    =SUMPRODUCT((Sheet1!$C$2:$E$9=Sheet2!G$2)*(Sheet1!$A$2:$A$9=Sheet2!$B3)*(Sheet1!$B$2:$B$9=Sheet2!$C3)*(Sheet1!$C$1:$E$1=Sheet2!$A3))
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: How to count number of occurrences in a table if certain criteria are met.

    You're right Ford. I had created my formula in a separate column set. The correct formula would be

    =SUMPRODUCT((Sheet1!$C$2:$E$9=Sheet2!D$2)*(Sheet1!$A$2:$A$9=Sheet2!$B3)*(Sheet1!$B$2:$B$9=Sheet2!$C3)*(Sheet1!$C$1:$E$1=Sheet2!$A3))

    2015-02-10_18-48-36.png

    Thanks for picking this up.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: How to count number of occurrences in a table if certain criteria are met.

    Thanks for the update, I was scratching my head trying to figure what I had missed

    @ VBAhelp3456 Please update your profile as necessary to properly reflect the exact version(s) of Excel your question relates to. Your profile indicates 2003, but your upload suggests a version 2007 or later?

  6. #6
    Registered User
    Join Date
    03-30-2014
    Location
    Australia
    MS-Off Ver
    Excel 2003 & 10
    Posts
    30

    Re: How to count number of occurrences in a table if certain criteria are met.

    Thanks everyone for your help.

    I subbed in your formula but for some reason my version turns up all zeros? Could you please tell me when I'm doing wrong?

    Thanks in advance
    Attached Files Attached Files

  7. #7
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: How to count number of occurrences in a table if certain criteria are met.

    Read my first post above with regards to the date values. If you don't read, I can't help.

  8. #8
    Registered User
    Join Date
    03-30-2014
    Location
    Australia
    MS-Off Ver
    Excel 2003 & 10
    Posts
    30

    Re: How to count number of occurrences in a table if certain criteria are met.

    I obviously overlooked the second part of your response - No need to be high and mighty about it!!!!!

  9. #9
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: How to count number of occurrences in a table if certain criteria are met.

    This is not about high and mighty. I take a lot of care with my replies. I test every formula and often back it up with screenshots. All I ask is that you take as much care reading my posts as I put into composing them. My intention is to help, not to offend.

    As you can see from the above exchange with Ford, I also make mistakes every once in a while and I'm not too proud to admit that.

    So we both goofed up in this thread. Does it matter?

    For me, the only thing that matters is if you got help here, be it from my posts or from someone else's.

+ 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] Count number of occurrences but if there are consecutive matches count them as one
    By michaljireht in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-26-2013, 08:26 PM
  2. count the number of occurrences when value meets 3 x criteria
    By tiggi in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-26-2013, 03:12 PM
  3. Count of occurrences until a criteria met
    By dazlan in forum Excel General
    Replies: 0
    Last Post: 02-12-2011, 09:27 AM
  4. Count unique occurrences with criteria
    By Alaina Readman in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-01-2007, 04:41 PM
  5. trying to COUNT occurrences when certain criteria is met
    By Allan from Melbourne in forum Excel General
    Replies: 4
    Last Post: 08-02-2006, 06:05 AM

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