+ Reply to Thread
Results 1 to 7 of 7

Subtract Sumproduct from a sumproduct

  1. #1
    Registered User
    Join Date
    03-28-2007
    Posts
    71

    Subtract Sumproduct from a sumproduct

    I have a situation where I need to collect all the information for a certain criteria, but then I need to subtract a certain combination of instance from that formula.

    I am including a simplified version of what I am looking for, as the idea of explaining the actual data gives me a bit of a headache. So, although this example doesn't exactly make sense, it is essentially what I am trying to do.

    So, my example has column A with animal names, Column B has colors, column C the item in question, column D the quantity.

    Here is the formula I am trying to get to work, however it is only answering the first half of the equation.

    =SUMPRODUCT((A2:A14="DOG")+(A2:A14="CAT"),--(B2:B14="BLUE")+
    B2:B14="yellow"),D2:D14)-SUMPRODUCT((A2:A14="CAT"),--(B2:B14="yellow"),D2:D14)


    So, basically, I want every instance where A equals Dog and Cat, and B equals blue and yellow, but then I want to subtract where the combination is Cat and yellow. Doesn't seem to matter what I do though, it is not subtracting.

    Please help!
    Last edited by Prcntrygrl; 01-17-2011 at 02:34 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Subtract Sumproduct from a sumproduct

    Try:

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Subtract Sumproduct from a sumproduct

    Instead of subtracting a subset, try only including what you want:
    Please Login or Register  to view this content.


    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Subtract Sumproduct from a sumproduct

    That's my second one..

  5. #5
    Registered User
    Join Date
    03-28-2007
    Posts
    71

    Re: Subtract Sumproduct from a sumproduct

    the problem is that this would work fantastically with the simple version. The actual spreadsheet is bu's and then certain operations from a process, then based on the work week and such and then I have to subtract a certain combination. So the formula is way too long to separate it all out. I've tried that too.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Subtract Sumproduct from a sumproduct

    Then perhaps you can add a column that concatenates columns A and B

    e.g. =A2&"_"&B2 copied down

    then you create a list of acceptable combinations separately.. (put an underscore between the 2 words) e.g. dog_blue, dog_yellow, cat_blue

    then use a formula like:

    =SUMPRODUCT(--(ISNUMBER(MATCH(E2:E14,N2:N10,0))),D2:D14)

    where E2:E14 contains the concatenated helper column, N2:N10 contains the list of combined acceptable strings.

  7. #7
    Registered User
    Join Date
    03-28-2007
    Posts
    71

    Re: Subtract Sumproduct from a sumproduct

    I had wanted to stay away from the concatenate, but now I'm wondering why. Thank you so much!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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