+ Reply to Thread
Results 1 to 12 of 12

SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula?)

  1. #1
    Forum Contributor
    Join Date
    10-15-2009
    Location
    Broooklyn, NY
    MS-Off Ver
    Excel 2016
    Posts
    207

    SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula?)

    I need to sum the values with non-continuous sum ranges and non-continuous multiple criteria. If data in BOTH columns B and C says No, then values should NOT be summed. See attached. The total in my example should be 24.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,369

    Re: SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula

    Try this:

    =SUMIFS(A2:A17,B2:B17,"<>No",C2:C17,"<>No")
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    10-15-2009
    Location
    Broooklyn, NY
    MS-Off Ver
    Excel 2016
    Posts
    207

    Re: SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula

    No, it's only sums up "Yes" in both columns, it has to sum up if the following variations are true
    1. Yes, Yes
    2. Yes, No
    3. No, Yes

  4. #4
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula

    This yields the desired result of 24:

    =SUMPRODUCT(A2:A17, --(--(B2:B17="yes")+(--(C2:C17="yes")) >= 1))
    Geoff

    Did I help significantly? If you wish, click on * Add Reputation to say thanks.
    If your problem has been resolved please select ?Solved? from the Thread Tools menu

  5. #5
    Forum Contributor
    Join Date
    10-15-2009
    Location
    Broooklyn, NY
    MS-Off Ver
    Excel 2016
    Posts
    207

    Re: SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula

    Can you explain it, specifically -- and >=1. I understand + acts as an OR operator. Is it correct?

  6. #6
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula

    I'm sure there's a more elegant way but this was the first thing I came up with.

    In this case the "+" is actually a normal arithmetic "+".
    1. B2:B17="yes" returns true or false. The --() around B2:B17="yes" coerces TRUE or FALSE to 1 or zero.
    2. The same logic applies to C2:C17="yes".
    3. So --(B2:B17="yes")+(--(C2:C17="yes")) = 2 if both B2 and C2 are "yes", 1 if (B2="yes" and C2="no") or (B2="no" and C2="yes") and 0 if both B2 and C2 are "no".
    4. So the only case we don't want to count is when B2 and C2 are both "no" and the above expression = 0 Hence the >=1 test.
    5. The outer wrapping --() is because sumproduct() won't automatically convert TRUE/FALSE to 1/0.
    6. Sumproduct does the above calculation row by row and we end up with an array of 1's and 0's which, finally, are multiplied by the array of values in A2:A17 and then summed to give the final result.

    Hopefully this clarifies what is happening rather than confuses!

    The best way to see what is happening during a formula evaluation is Excel's "Formulas > Evaluate-formula feature. It will show you step by step how Excel evaluates a formula.

  7. #7
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula

    Here's a somewhat more straightforward option!
    =SUMPRODUCT(A2:A17, --NOT((B2:B17="no")*(C2:C17="no")))

  8. #8
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,776

    Re: SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula

    A
    B
    C
    D
    E
    1
    Values Data1 Data2
    2
    2
    Yes Yes
    24
    3
    1
    Yes No
    4
    4
    No No
    5
    4
    No Yes
    6
    4
    No No
    7
    2
    Yes Yes
    8
    Other info1
    9
    3
    No No
    10
    1
    No Yes
    11
    5
    No No
    12
    2
    Yes Yes
    13
    Other info2
    14
    1
    No No
    15
    4
    No Yes
    16
    2
    No No
    17
    8
    Yes Yes



    E2=SUMPRODUCT=(--(ISERROR(SEARCH($B$4&C4,$B$2:$B$17&C2:C17))),A2:A17)

  9. #9
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula

    @CARACALLA You have a typo in the above formula. A superfluous "=" after SUMPRODUCT

  10. #10
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,776

    Re: SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula

    A
    B
    C
    D
    E
    F
    1
    Values Data1 Data2
    2
    2
    Yes Yes
    24
    3
    1
    Yes No
    4
    4
    No No
    5
    4
    No Yes
    6
    4
    No No
    7
    2
    Yes Yes
    8
    Other info1
    9
    3
    No No
    10
    1
    No Yes
    11
    5
    No No
    12
    2
    Yes Yes
    13
    Other info2
    14
    1
    No No
    15
    4
    No Yes
    16
    2
    No No
    17
    8
    Yes Yes



    F2=SUMPRODUCT(--(ISERROR(SEARCH($B$4&C4,B2:B17&C2:C17))),A2:A17)

  11. #11
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,198

    Re: SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula

    If the other info is not numeric, the formula will error as it can not sum the values, if this is the case
    =SUM(A2:A17)-SUMIFS(A2:A17,B2:B17,"No",C2:C17,"No") might be the answer

    but you are not telling us the problems with the previous solutions

  12. #12
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,029

    Re: SUM with multiple non-continuous criteria and non-continuous sum ranges (array formula

    Another option
    =SUMPRODUCT(SIGN((B2:B17="Yes")+(C2:C17="Yes")),A2:A17)

+ 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. Formula not conditionally filling highest value in non-continuous ranges
    By Ochimus in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-04-2019, 09:38 AM
  2. Creating a continuous graph with non-continuous data
    By Throwaway1234567 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-04-2017, 01:33 PM
  3. [SOLVED] Copy Non-Continuous Cells from One Sheet to Continuous Column on Other Sheet
    By catnam in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-13-2015, 05:29 PM
  4. [SOLVED] recalculating values across non continuous ranges
    By dvault101 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-13-2015, 04:28 PM
  5. [SOLVED] Non continuous array
    By mikmonto in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-02-2013, 09:34 AM
  6. Replies: 0
    Last Post: 02-20-2012, 05:42 PM
  7. User input from non-continuous ranges
    By vbanoob2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-24-2011, 01:36 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