+ Reply to Thread
Results 1 to 4 of 4

COUNTIFS function with ANDs and ORs

  1. #1
    Registered User
    Join Date
    02-16-2012
    Location
    Adelaide
    MS-Off Ver
    Excel 2003
    Posts
    42

    COUNTIFS function with ANDs and ORs

    Hi and thanks in advance.

    I am trying to construct a COUNTIFS function that utilizes ANDs and ORs without much success.

    I have a sheet that has a 1000 rows of data and I am trying to count the number of rows where the following is true ...

    Column A = "WP"
    AND
    Column B <> "Target" AND Column B <> "Sorted"
    AND
    Column C = "Second"
    AND
    (Column D = "Fail" OR Column E = "Fail" OR Column F = "Fail" OR Column G = "Fail" OR Column H = "Fail" OR Column I = "Fail")

    Started mucking about with COUNTIFS and curly brackets and SUM function but not really sure how to do this.

    Thanks

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: COUNTIFS function with ANDs and ORs

    hi Deutz. you can use this if "fail" only appears once:
    =SUMPRODUCT((A2:A20="WP")*(B2:B20<>"Target")*(B2:B20<>"Sorted")*((D2:I20="Fail")))

    or this if it can appear more than once in any columns:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: COUNTIFS function with ANDs and ORs

    =COUNTIFS(A1:A1000,"WP",B1:B1000,"<>"&"Target",B1:B1000,"<>"&"Sorted",C1:C1000,"Second")-COUNTIFS(A1:A1000,"WP",B1:B1000,"<>"&"Target",B1:B1000,"<>"&"Sorted",C1:C1000,"Second",D1:D1000,"<>"&"Fail",E1:E1000,"<>"&"Fail",F1:F1000,"<>"&"Fail",G1:G1000,"<>"&"Fail",H1:H1000,"<>"&"Fail",I1:I1000,"<>"&"Fail")
    Try this
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  4. #4
    Registered User
    Join Date
    02-16-2012
    Location
    Adelaide
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: COUNTIFS function with ANDs and ORs

    Thanks benishiryo and nflsales for your solutions which I have tested and work fine.

    Sorry but I forget to include one extra column in the criteria. Managed to get it working in the COUNTIFS example but not in the first SUMPRODUCT solution where Fail can appear only once.

    Need to add column U to the OR part.

    So revised criteria is ...

    Column A = "WP"
    AND
    Column B <> "Target" AND Column B <> "Sorted"
    AND
    Column C = "Second"
    AND
    (Column U = "Fail" OR Column D = "Fail" OR Column E = "Fail" OR Column F = "Fail" OR Column G = "Fail" OR Column H = "Fail" OR Column I = "Fail")
    Last edited by Deutz; 06-27-2014 at 12:01 AM.

+ 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] Ifs ands countifs
    By HCBalelo in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-26-2012, 01:34 PM
  2. Replies: 0
    Last Post: 12-16-2011, 09:01 AM
  3. CountIFS / Ands or Buts :)
    By Rino468 in forum Excel General
    Replies: 3
    Last Post: 07-08-2011, 01:56 PM
  4. IF with two ANDs and 3 answers
    By jomili in forum Excel General
    Replies: 6
    Last Post: 10-26-2010, 01:12 PM
  5. Nesting ,Ands
    By teresa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-07-2005, 11:06 AM

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