+ Reply to Thread
Results 1 to 9 of 9

Help with SUMIFS function

  1. #1
    Registered User
    Join Date
    06-01-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    20

    Help with SUMIFS function

    Dear Excel Users!

    This seems so clear to me but I can't understand how to get it to work, I feel really stupid!

    example:

    SUMIFS-help.jpg

    I want to sum the values of "apple" & "banana" only when both are present within the same ID.

    First I wrote the formula:

    =SUMIFS(C$2:C$11,A$2:A$11,D2,B$2:B$11,"apple",B$2:B$11,"banana")

    but that doesn't work. So then I tried:

    =SUMIFS(C$2:C$11,A$2:A$11,D2,B$2:B$11,"apple"&"banana")

    or variations

    =SUMIFS(C$2:C$11,A$2:A$11,D2,B$2:B$11,"*apple*"&"*banana*")
    =SUMIFS(C$2:C$11,A$2:A$11,D2,B$2:B$11&B$2:B$11,"apple"&"banana")

    they don't work....

    my logic is probably wrong and I'm not understanding how SUMIFS works. It's frustrating!

    I've tried playing around with using IF and AND functions but no luck.

    Any help would be greatly appreciated!

    Thank you
    Last edited by SamFitz; 09-26-2016 at 01:07 PM.

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help with SUMIFS function

    Try
    =SUM(SUMIFS(C$2:C$11,A$2:A$11,D2,B$2:B$11,{"apple","banana"}))

  3. #3
    Registered User
    Join Date
    06-01-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    20

    Re: Help with SUMIFS function

    Hi Jonmo1,

    Thank you very much for replying, the formula partly works but it also sums when there is an ID with "apple" and not "banana".
    I would like it to sum the values of "apple" & "banana" when both are present within the same ID, if only one is present the result should be 0.

    So in the example the results I am after in cells E2 to E5 are:

    500
    0
    0
    600

    I've tried tweaking your formula but with no luck, can you help?

    Thank you very much

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help with SUMIFS function

    Try

    =IF(SUM(--(COUNTIFS($A$2:$A$11,D2,$B$2:$B$11,{"apple","banana"})>0))=2,SUM(SUMIFS(C$2:C$11,A$2:A$11,D2,B$2:B$11,{"apple","banana"})),0)

  5. #5
    Registered User
    Join Date
    06-01-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    20

    Re: Help with SUMIFS function

    Thank you Jonmo1 that's great!

    I was trying with IF, AND and OR functions but didn't consider your solution with COUNTIFS, which seems very neat and works very well! Thank you!

    I do have one question about how the formula is working if that's ok?

    For instance if I have an ID with two "apple" entries and no "banana", giving an array {2,0} how does that change to {TRUE,FALSE}?

    I get that the double dash changes it from {TRUE,FALSE} to {1,0}.

    Thank you

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help with SUMIFS function

    You're welcome.

    If you think about how this syntax works
    SUM(SUMIFS(C$2:C$11,A$2:A$11,D2,B$2:B$11,{"apple","banana"}))

    It's essentially doing 2 sumifs formulas (1 for apple, 1 for banana), and summing the results of each.
    A shortcut for
    SUM(SUMIFS(C$2:C$11,A$2:A$11,D2,B$2:B$11,"apple"),SUMIFS(C$2:C$11,A$2:A$11,D2,B$2:B$11,"banana"))


    Similarly, in the initial IF I used this
    SUM(--(COUNTIFS($A$2:$A$11,D2,$B$2:$B$11,{"apple","banana"})>0))
    This is adding the >0 operator to each countifs and returning True or False for them.
    The -- is converting the true/false to 1/0
    Then it's summed.
    Basically doing
    SUM(--(COUNTIFS($A$2:$A$11,D2,$B$2:$B$11,"apple")>0),--(COUNTIFS($A$2:$A$11,D2,$B$2:$B$11,"banana")>0))

    Only if both are true will that sum =2
    If that sum does =2, then do the sum(sumifs

    Hope that helps.
    Last edited by Jonmo1; 09-27-2016 at 01:21 PM.

  7. #7
    Registered User
    Join Date
    06-01-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    20

    Re: Help with SUMIFS function

    Thank you very much for the explanation!

    Of course the operator greater than is what changes the countifs to True or False, it makes perfect sense, and very useful to see how the syntax is working.

    A very clever simple formula and great to see how it is put together, that really helps with my understanding of formulas in excel.

    Thank you again!

  8. #8
    Registered User
    Join Date
    06-01-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    20

    Re: Help with SUMIFS function

    Thank you very much for the explanation!

    Of course the operator greater than is what changes the countifs to True or False, it makes perfect sense, and very useful to see how the syntax is working.

    A very clever simple formula and great to see how it is put together, that really helps with my understanding of formulas in excel.

    Thank you again!

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help with SUMIFS function

    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. [SOLVED] Using large function based on sumifs function
    By jeosen in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-26-2015, 08:20 AM
  2. [SOLVED] Help with this SUMIFS function
    By husni in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-09-2015, 01:28 AM
  3. [SOLVED] Sumifs / or function help
    By HATLET in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-03-2014, 11:06 AM
  4. Help nesting an OR function inside a SUMIFS function
    By wes228 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-21-2014, 06:22 PM
  5. [SOLVED] sumifs function
    By orshims in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-07-2014, 10:56 AM
  6. [SOLVED] Sumifs Function
    By madness in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-09-2013, 02:47 PM
  7. [SOLVED] SUMIFS function?
    By jed38 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2012, 04:33 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