+ Reply to Thread
Results 1 to 7 of 7

OR conditions in a SUMPRODUCT formula

  1. #1
    Registered User
    Join Date
    05-13-2010
    Location
    New Brunwsick, Canada
    MS-Off Ver
    Excel 2013
    Posts
    22

    Question OR conditions in a SUMPRODUCT formula

    I am using SUMPRODUCT to build a stats page for a report. I need a lot of different combos of the data and SUMPRODUCT usually works like a charm for me. But I'm stuck. In this particular case I have two columns, each containing multiple values. I want to pull data for a subset of values from each of those columns (using "<>" multiple times will be just as onerous).

    I'd like to try to keep it simple.... and had hoped that something like this would work. But this returns an error.
    =SUMPRODUCT((Severity={"BI","NI","XY"})*(Type<>"Duplicate")*(Time<5)*(Source={"A1","A6","A7","A12"}))

    I can get it to work with this option but this means that my formulas will become very long.
    =SUMPRODUCT((Severity="BI")*(Type<>"Duplicate")*(Time<5)*(Source={"A1","A6","A7","A12"}))+SUMPRODUCT((Severity="NI")*(Type<>"Duplicate")*(Time<5)*(Source={"A1","A6","A7","A12"}))+SUMPRODUCT((Severity="XY")*(Type<>"Duplicate")*(Time<5)*(Source={"A1","A6","A7","A12"}))

    I tried using an OR condition for the Severity but that gave me the wrong value. I played around a bit thinking it might need to be treated as an array formula, but that was a disaster. I feel like I'm missing something simple.... or that I really will have to build long formulas.

    Any ideas or suggestions?
    Last edited by razz0807; 08-26-2015 at 01:52 PM. Reason: Corrected formula that I had stated worked.

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,645

    Re: OR conditions in a SUMPRODUCT formula

    Without a sample for testing, not sure it can help, but try:

    =SUMPRODUCT(--((((Severity="BI")+(Severity="NI")+(Severity="XY"))=2)*(Type<>"Duplicate")*(Time<5)*(((Source="A1")+(Source="A6")+(Source="A7")+(Source="A12"))=2)))
    Quang PT

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,645

    Re: OR conditions in a SUMPRODUCT formula

    Sorry, may be I 've made wrong formula with previous post, pls update:

    =SUMPRODUCT(--((((Severity="BI")+(Severity="NI")+(Severity="XY")+(Source="A1")+(Source="A6")+(Source="A7")+(Source="A12"))=2)*(Type<>"Duplicate")*(Time<5)))

  4. #4
    Registered User
    Join Date
    05-13-2010
    Location
    New Brunwsick, Canada
    MS-Off Ver
    Excel 2013
    Posts
    22

    Cool Re: OR conditions in a SUMPRODUCT formula

    Thank you. That corrected formula you posted worked like a charmed.

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,645

    Re: OR conditions in a SUMPRODUCT formula

    Thanks for the rep. Good luck!

  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: OR conditions in a SUMPRODUCT formula

    Quote Originally Posted by razz0807 View Post
    =SUMPRODUCT((Severity={"BI","NI","XY"})*(Type<>"Duplicate")*(Time<5)*(Source={"A1","A6","A7","A12"}))
    Are the named ranges 1 dimensional ranges? (single row or single column)?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695

    Re: OR conditions in a SUMPRODUCT formula

    Assuming all the named ranges have the same dimensions you can use COUNTIFS like this

    =SUM(COUNTIFS(Severity,{"BI","NI","XY"},Type,"<>Duplicate",Time,"<5",Source,{"A1";"A6";"A7";"A12"}))

    Note: for this type of formula you can't have more than 2 "multi-item" criteria - also one of the arrays needs to be separated by commas and the other by semi-colons, hence {"A1";"A6";"A7";"A12"} in my version rather than {"A1","A6","A7","A12"}
    Audere est facere

+ 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] Simplest formula for sumproduct with or conditions
    By lejanco in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-17-2015, 04:06 PM
  2. Excel formula to sumproduct but with multiple conditions
    By Dani8826 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-07-2014, 04:25 AM
  3. SUMPRODUCT with conditions
    By Steve_Courts in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-24-2013, 05:33 AM
  4. Squeezing more conditions into a sample SUMPRODUCT formula - show a novice pls!
    By RogerRangeRover in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-01-2012, 06:33 AM
  5. sumproduct with if conditions
    By Unnati in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-10-2012, 03:53 AM
  6. sumproduct with 2 conditions
    By tek9step in forum Excel General
    Replies: 4
    Last Post: 02-16-2011, 09:37 AM
  7. SUMPRODUCT-formula with changing conditions
    By BCB in forum Excel General
    Replies: 2
    Last Post: 02-09-2009, 04:49 PM

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