+ Reply to Thread
Results 1 to 7 of 7

COUNTIFS for several criteria with the AND logic.

  1. #1
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    COUNTIFS for several criteria with the AND logic.

    Hi all,

    Basically I am using the COUNTIF formula to find out if several specific values are present in a range, Below is my formula in cell B1:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    with cells from range A1 to A10 containing values such as DI1, DI2, DI3...

    The issue is that my formula, although it works, can become very long and eventually goes above the maximum number of allowed characters for a cell, hence I am trying to optimise it to make it shorter.

    I tried using
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    in my formula but it is for the OR logic, i.e. DI1 or DI2 or DI3.

    What I need is the same as above but for the AND logic, i.e. DI1 and DI2 and DI3. Would anyone know the correct syntax?

    Thanks.
    Last edited by Folshot; 01-27-2020 at 01:14 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: COUNTIFS for several criteria with the AND logic.

    Yes, COUNTIFS uses AND logic to join all conditions:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Re: COUNTIFS for several criteria with the AND logic.

    The formula only works if I use one single criteria, i.e.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    , if I use several criteria it only returns 0 no matter the content of range A1:A10.

  4. #4
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: COUNTIFS for several criteria with the AND logic.

    You could use this slightly shorter version

    =IF(COUNTIF($A$1:$A10,"DI1")*COUNTIF($A$1:$A10,"DI2")*COUNTIF($A$1:$A10,"DI3"),HYPERLINK("#'DI4'!A1","DI4"),
    IF(COUNTIF($A$1:$A10,"DI1")*COUNTIF($A$1:$A10,"DI2"),HYPERLINK("#'DI3'!A1","DI3"),
    IF(COUNTIF($A$1:$A10,"DI1")>0,HYPERLINK("#'DI2'!A1","DI2"),
    HYPERLINK("#'DI1'!A1","DI1"))))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  5. #5
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: COUNTIFS for several criteria with the AND logic.

    Try this (for example), which will tell you if all three values occur in the list:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  6. #6
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Re: COUNTIFS for several criteria with the AND logic.

    Thanks Ace_XL, it works though not reducing it enough.

    Thanks WBD, I did a quick test and seems to work great, I am going to implement it. It is very impressive, it reduce the size of the formula so much, very efficient indeed!

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: COUNTIFS for several criteria with the AND logic.

    Quote Originally Posted by Folshot View Post
    The formula only works if I use one single criteria, i.e.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    , if I use several criteria it only returns 0 no matter the content of range A1:A10.
    Sorry, I got that completely wrong. The formula I provided will count the number of cells that have all three values (in each cell), which of course is zero.

+ 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] COUNTIFS formula to count for 2 criteria inside one criteria area
    By signekolind in forum Excel General
    Replies: 4
    Last Post: 08-07-2019, 04:39 AM
  2. [SOLVED] Countifs multiple criteria- criteria if cell is greater than another i adjacent column
    By Sircool1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-26-2018, 11:23 AM
  3. [SOLVED] Countifs one criteria range multi dynamic cells as criteria
    By brake in forum Excel Formulas & Functions
    Replies: 26
    Last Post: 03-10-2018, 08:00 AM
  4. COUNTIFs: Multiple ranges, single criterion with OR logic
    By A.Khan in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-20-2017, 06:05 AM
  5. [SOLVED] CountIFS using criteria in one cell OR another - OR logic?
    By trubertiam in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-01-2014, 08:48 PM
  6. Replies: 2
    Last Post: 11-06-2012, 06:40 PM
  7. Help with COUNTIFS logic with monthly date criteria.
    By cbreeze in forum Excel General
    Replies: 2
    Last Post: 02-16-2012, 12:16 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