+ Reply to Thread
Results 1 to 9 of 9

Count If Formula for 2 Separate Criteria Not Correct

  1. #1
    Registered User
    Join Date
    05-22-2017
    Location
    Houston, Texas
    MS-Off Ver
    2013/2016
    Posts
    20

    Count If Formula for 2 Separate Criteria Not Correct

    Hello All,

    I am trying to write a CountIf Excel formula to calculate 2 separate criteria for a range. The range consists of an If formula that generates either a 1 or a 2, so the Countif will tell the user what category that range is ( 1 or 2). The formula works when it is only for one criteria but I can't get it to work when I add a second CountIf. I appreciate you taking time to read my post. Please let me know if you have any suggestions, thank you!

    1 criteria which works =IF(COUNTIF(M14:AR14,"*"&"1"&"*"),"Check","x")

    2 criteria =IF(COUNTIF(M14:AR14,"*"&"1"&"*"),"Check",IF(COUNTIF(M14:AR14,"*"&"4"&"*"),"Clear","x"))
    Attached Files Attached Files
    Last edited by wooshoe; 05-17-2019 at 12:30 PM.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Count If Formula for 2 Separate Criteria Not Correct

    Translating formula 1 into words: If there are any cells in row 14 that contain a 1, then return "check". If not, return "x".
    Translating formula 2 into words: If there are any cells in row 14 that contain a 1, then return "check". If not, then test if there are any cells in row 14 that contain a 4. If any cells contain a 4, then return "Clear". If not return "x".

    Your description of what is in row 14 suggests that the cells in row 14 will either be a 1 or a 2, but never a 4. If that is correct, then formula 2 will return "Check" when it is a 1, an "x" when it is a 2, and will never return "Clear".

    From there, I am not sure exactly what logic you are trying to implement here, so I cannot suggest any corrections or changes.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Count If Formula for 2 Separate Criteria Not Correct

    Please upload a workbook or a representative cut down copy, anonymised if necessary. It is always easier to advise if we can see your request in its context.

    Show a before and after situation with manually calculated results, explaining which information is data and which is results, and if it's not blindingly obvious how you have arrived at your results some explanatory notes as well.

    To upload a file click the Go Advanced button at the foot of your post, look underneath the post area for the Manage Attachments section and take it from there.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    05-22-2017
    Location
    Houston, Texas
    MS-Off Ver
    2013/2016
    Posts
    20

    Re: Count If Formula for 2 Separate Criteria Not Correct

    Hi Richard,

    Thank you for the suggestion. I have posted an example of the worksheet issue I am dealing with. The CountIf formula is searching through a series of If functions for '4' or '1', so that may be why it is not pulling the right results. Please let me know if my example workbook is clear.

  5. #5
    Valued Forum Contributor
    Join Date
    01-07-2013
    Location
    Michigan
    MS-Off Ver
    O365
    Posts
    601

    Re: Count If Formula for 2 Separate Criteria Not Correct

    You should just be able to use:
    Please Login or Register  to view this content.
    Does that give you the results you're looking for?
    If someone helped achieve your solution, consider clicking "* Add Reputation" on their post.

    If your question has been answered, mark the thread as [SOLVED] using the Thread Tools menu at the top of the thread.

  6. #6
    Registered User
    Join Date
    05-22-2017
    Location
    Houston, Texas
    MS-Off Ver
    2013/2016
    Posts
    20

    Re: Count If Formula for 2 Separate Criteria Not Correct

    Thank you Melvosh, your suggestion works and gives me what I am looking for! I just realized though that this formula doesn't achieve what I really need, which is if the range has a 4 AND it is equal to today's date, then Check.

  7. #7
    Valued Forum Contributor
    Join Date
    01-07-2013
    Location
    Michigan
    MS-Off Ver
    O365
    Posts
    601

    Re: Count If Formula for 2 Separate Criteria Not Correct

    If I understand what you're trying to do, this should work:
    Please Login or Register  to view this content.
    If the date a 4 is found on is equal to today, Check will show.

  8. #8
    Registered User
    Join Date
    05-22-2017
    Location
    Houston, Texas
    MS-Off Ver
    2013/2016
    Posts
    20

    Re: Count If Formula for 2 Separate Criteria Not Correct

    So I had to move the IF logic to capture 4 ahead of the IF logic to capture instances of 1.

    IF(COUNTIF(M12:AR12,4),"Check",IF(COUNTIF(M12:AR12,1),"Clear","x"))

    Using that order, I attempted to apply your formula. The first part of it works.

    IFERROR(IF(AND(COUNTIF(M12:AR12,4),INDEX($M$11:$AR$11,MATCH(4,M12:AR12,0))<=TODAY()),"Paid","x")---- but I cannot get the second portion of it down for instances of 1 ----,IF(COUNTIF(M12:AR12,1),"Payable"))

  9. #9
    Valued Forum Contributor
    Join Date
    01-07-2013
    Location
    Michigan
    MS-Off Ver
    O365
    Posts
    601

    Re: Count If Formula for 2 Separate Criteria Not Correct

    The ranges you mentions are different, but this should work in your workbook from post #1, in cell A4 on sheet End:
    Please Login or Register  to view this content.
    If I've got the ranges right, this should work for your updated ranges:
    Please Login or Register  to view this content.
    Does that give you the results you're looking for?

+ 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] Sumproduct formula not giving correct count
    By mmccra2858 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-03-2017, 01:59 PM
  2. [SOLVED] correct If formula with three criteria
    By mazan2010 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-01-2016, 03:02 PM
  3. [SOLVED] Correct syntax for referencing a separate worksheet in a formula when.
    By moosetales in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-20-2014, 03:01 PM
  4. [SOLVED] How can I count line entries based on meeting criteria for 2 separate columns?
    By neilrk7 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-15-2013, 12:57 PM
  5. Am I correct in using the IF formula for 6 criteria?
    By danny2324 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-24-2008, 01:50 PM
  6. [SOLVED] How do I count data with criteria from two separate columns in exc
    By Scott in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-02-2006, 12:25 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