+ Reply to Thread
Results 1 to 4 of 4

counting number of occurences since last bad item

  1. #1
    Registered User
    Join Date
    06-26-2012
    Location
    Limerick, Ireland
    MS-Off Ver
    Excel 2016
    Posts
    52

    counting number of occurences since last bad item

    Hello,

    I'm looking to get a formula which will count the number of entries based on criteria of number of good entries since last known bad entry. I have tried to explain this in the attached spreadsheet.

    Column A→C = rawdata
    Col A = Item
    Col B = Good / Bad
    Col C = Quantity

    In column D i have added the expected result
    D8 = 2 as opposed to a count of Col A = "Apples" and Col B result = "Good", a standard countif which would return 3 (Row 2,6 + 8) but as row 5 has Col B result as "Bad" i need to start the counter again to just include row 6 + 8
    Attached Files Attached Files
    Last edited by brian_2me; 06-16-2020 at 09:25 AM. Reason: Rule 1

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: CountIF

    Administrative Note:

    We would very much like to help you with your query, however the thread title does not really convey what your request is about. Tell us what you are trying to do, not how you think it should be done.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,619

    Re: CountIF

    1) Edit the title of the post, because as it is now it's against rule 1 of: https://www.excelforum.com/forum-rul...rum-rules.html
    something like "counting number of occurences since last bad item" or may be adding "conditional counting number of occurences since last bad item" etc.


    2) Use such array formula in D2 and copy it down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    But please do not forget about point 1) above.

    3) Note that we are comparing column B values with Good_and_two_spaces - your data has such values in column B

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Best Regards,

    Kaper

  4. #4
    Registered User
    Join Date
    06-26-2012
    Location
    Limerick, Ireland
    MS-Off Ver
    Excel 2016
    Posts
    52

    Re: CountIF

    Thanks very much, works perfect. Corrected post title as per your suggestion

+ 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. Adding a COUNTIF function to an existing IF AND COUNTIF Formula...
    By Ourkid123uk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-24-2018, 10:09 AM
  2. Replies: 8
    Last Post: 05-27-2017, 07:04 AM
  3. Faster if/countif formula for flagging uniques - countif too slow
    By Speshul in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-19-2015, 01:44 PM
  4. Combining a Date Range COUNTIF and a general COUNTIF
    By jacobtom in forum Excel General
    Replies: 1
    Last Post: 09-15-2011, 05:06 PM
  5. Adding a CountIF to a formula that is already Countif
    By Cmorgan in forum Excel General
    Replies: 4
    Last Post: 06-01-2011, 09:34 AM
  6. [SOLVED] COUNTIF or not to COUNTIF on a range in another sheet
    By Ellie in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-15-2005, 05:06 PM
  7. Countif w/ Multiple Criteria-How do I use countif
    By Patrick_KC in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-09-2005, 05: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