+ Reply to Thread
Results 1 to 8 of 8

help nesting OR statement into COUNTIFS statement

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    help nesting OR statement into COUNTIFS statement

    I have 5 total criteria for a COUNTIFS statement, but the first 3 criteria are true regardless:

    Formula: copy to clipboard
    =COUNTIFS(RangeA,CriteriaA,RangeFromDate,">="&$B$2,RangeToDate,"<="&$B$3)


    Next I need an OR statement that will return my count if, for example, RangeB with criteriaB is true - OR - if RangeC with CriteriaC either one is true.

    Of course, if my data meets both Range/Criteria B and C, then it will only count once, right?

    Any help is greatly appreciated, as always!

    -HeyInKy

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: help nesting OR statement into COUNTIFS statement

    Try this...

    =SUMPRODUCT(--(RangeA=CriteriaA),--(RangeFromDate>=$B$2),--(RangeToDate<=$B$3),SIGN((RangeB=CriteriaB)+(RangeC=CriteriaC)))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: help nesting OR statement into COUNTIFS statement

    Quote Originally Posted by Tony Valko View Post
    Try this...

    =SUMPRODUCT(--(RangeA=CriteriaA),--(RangeFromDate>=$B$2),--(RangeToDate<=$B$3),SIGN((RangeB=CriteriaB)+(RangeC=CriteriaC)))
    Ok, a follow-up request came in to add one more "OR" criteria... would I just add the new condition to the SIGN function with another "+" such as:

    Formula: copy to clipboard
    =SUMPRODUCT(--(RangeA=CriteriaA),--(RangeFromDate>=$B$2),--(RangeToDate<=$B$3),SIGN((RangeB=CriteriaB)+(RangeC=CriteriaC)+(Range D=RangeD)))


    ...and would that function as an "OR" for either criteria B, C or D?

    Thanks!

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: help nesting OR statement into COUNTIFS statement

    Quote Originally Posted by HeyInKy View Post

    =SUMPRODUCT(--(RangeA=CriteriaA),--(RangeFromDate>=$B$2),--(RangeToDate<=$B$3),SIGN((RangeB=CriteriaB)+(RangeC=CriteriaC)+(Range D=RangeD)))

    ...and would that function as an "OR" for either criteria B, C or D?
    Yes, but you probably meant: +(RangeD=CriteriaD).

  5. #5
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: help nesting OR statement into COUNTIFS statement

    Yepp... Excellent. Bravo!

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: help nesting OR statement into COUNTIFS statement

    You're welcome. Thanks for the feedback!

  7. #7
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: help nesting OR statement into COUNTIFS statement

    Yes, I did. Thanks.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: help nesting OR statement into COUNTIFS statement

    You're welcome!

+ 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. IF statement nesting levels
    By rod642 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-23-2014, 10:53 AM
  2. Nesting IF Statement
    By firehousetk in forum Excel General
    Replies: 8
    Last Post: 11-28-2011, 12:22 PM
  3. Excel 2007 : Nesting IF Statement
    By anitad in forum Excel General
    Replies: 3
    Last Post: 06-29-2011, 11:43 PM
  4. If statement nesting
    By msbing916 in forum Excel General
    Replies: 4
    Last Post: 05-07-2010, 03:38 PM
  5. Nesting If Statement? or another way
    By tclark14 in forum Excel General
    Replies: 7
    Last Post: 01-18-2005, 11:04 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