+ Reply to Thread
Results 1 to 9 of 9

How to sum values based on multiple criteria with multple possibilities for each criteria?

  1. #1
    Registered User
    Join Date
    01-05-2013
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    4

    How to sum values based on multiple criteria with multple possibilities for each criteria?

    Hi,

    I encounter some problem when trying to sum based on multiple criteria. My data is something like this

    Cat Sherry 10
    Cat Ben 5
    Cat Ken 2
    Dog Sherry 2
    Dog Ben 1
    Dog Ken 6
    Fish Sherry 15
    Fish Ben 1
    Fish Ken 7

    I have 2 criteria: Animal and owner
    What I hope to do is to sum up all the values in the 3rd column that belongs to Cat and Dog under animal and Sherry and Ben under owner. So I will like to get the sum of 18 (10+5+2+1) Is there a way to do this with a formula?

    Thank you in advance for any help given!
    Last edited by boredaxel; 11-04-2013 at 12:37 PM.

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: How to sum values based on multiple criteria with multple possibilities for each crite

    Please see attached file with formulas.
    Attached Files Attached Files
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How to sum values based on multiple criteria with multple possibilities for each crite

    Quote Originally Posted by boredaxel View Post
    What I hope to do is to sum up all the values in the 3rd column that belongs to Cat and Dog under animal and Sherry and Ben under owner.
    Try this formula

    =SUM(SUMIFS(C:C,A:A,{"cat","dog"},B:B,{"sherry";"ben"}))
    Audere est facere

  4. #4
    Registered User
    Join Date
    01-05-2013
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: How to sum values based on multiple criteria with multple possibilities for each crite

    Hi Alkey, thanks for the help. I am hoping to use a formula without having to manipulate my original table. I forgot to mention that I have another table containing the criteria:

    Criteria
    Cat Sherry
    Dog Ben

    Is there a way to do it? I tried sumifs but it only gives me the sum for sherry's cat and ben's dog but excluded sherry's dog and ben's cat

  5. #5
    Registered User
    Join Date
    01-05-2013
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: How to sum values based on multiple criteria with multple possibilities for each crite

    Hi daddylonglegs,

    Thank you for the advice. I tried your formula but unfortunately it gives me only the sum of sherry & cat and ben & dog, leaving out sherry&dog and ben&cat, which I would also want in the sum.

    I have a range of cells containing the criteria such as:

    Criteria
    Cat Sherry
    Dog Ben

    The aim is so that I can change the criteria and vary the sum.

    Is there a way to do that?

  6. #6
    Valued Forum Contributor
    Join Date
    02-05-2013
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2013
    Posts
    571

    Re: How to sum values based on multiple criteria with multple possibilities for each crite

    Modify formula from daddylonglegs it's array formula so don't forget press ctrl+shift+enter
    Attached Files Attached Files
    Click (*) if you received helpful response.

    Regards,
    David

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

    Re: How to sum values based on multiple criteria with multple possibilities for each crite

    ....but that gives a result of 11 - isn't the answer 18? (sum of C2, C3, C5 and C6)

    I think my formula gives that answer

    =SUM(SUMIFS(C:C,A:A,{"cat","dog"},B:B,{"sherry";"ben"}))

    [doesn't need array entry]

    Note that in {"cat","dog"} there is a comma separator and in {"sherry";"ben"} there is a semi-colon. It has to be written that way (or the first with semi-colon the second with comma)

    If you have the criteria in columns as shown in SDCh's sheet then you need to use TRANSPOSE on one of them, i.e.

    =SUM(SUMIFS(C2:C15,A2:A15,F2:F5,B2:B15,TRANSPOSE(G2:G5)))

    confirmed with CTRL+SHIFT+ENTER

    ....or a non-array version like this will be more "extensible", e.g. if you want more multi-option criteria

    =SUMPRODUCT(ISNUMBER(MATCH(A2:A15,F2:F5,0))*ISNUMBER(MATCH(B2:B15,G2:G5,0)),C2:C15)
    Last edited by daddylonglegs; 11-04-2013 at 12:41 PM.

  8. #8
    Registered User
    Join Date
    01-05-2013
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: How to sum values based on multiple criteria with multple possibilities for each crite

    Hi SDCh,

    Thank you for this Unfortunately, what I want is 18. (cat&sherry 10 + cat&ben 5 + dog&sherry 2 + dog&ben 1). Sumifs just give me cat&sherry 10 + dog&ben 1, obmitting the other 2 values. Is there a way to get the sum i want? sorry I did not make it clear in my original post

  9. #9
    Registered User
    Join Date
    01-05-2013
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: How to sum values based on multiple criteria with multple possibilities for each crite

    Hi daddylonglegs,

    You are right, it does give 18. Sorry for my mistake. I tried your formula by replacing ,{"cat","dog"}, and ,{"sherry";"ben"} with the cells containing the criteria e.g. (e2:e3) and (f2:f3). That gave me a sum of 11 instead of 18. What you suggested with the transpose works! Thanks!!
    Last edited by boredaxel; 11-04-2013 at 12:44 PM.

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: How to sum values based on multiple criteria with multple possibilities for each crite

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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. Replies: 4
    Last Post: 05-19-2015, 11:53 PM
  2. [SOLVED] SUMIFS with multiple possibilities as each criteria
    By mozhils in forum Excel General
    Replies: 10
    Last Post: 11-05-2012, 10:00 AM
  3. [SOLVED] Deleting multiple rows with specific criteria in multple columns
    By cb10 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2012, 10:16 AM
  4. Counting multple criteria in multiple cells.
    By JapanDave in forum Excel General
    Replies: 6
    Last Post: 05-12-2009, 01:30 AM
  5. [SOLVED] How to lookup and sum multiple values based on multple columns
    By Ray Gans in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2005, 07:05 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