+ Reply to Thread
Results 1 to 10 of 10

Double Conditional in SUMIF

  1. #1
    Registered User
    Join Date
    01-20-2013
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2003
    Posts
    48

    Double Conditional in SUMIF

    I need the equivalent of a double conditional in the Function SUMIF.

    In my example (a test file is attached), I have used hypothetical stock trades as a test case.

    Column B has the type of order (Buy or Sell).
    Column C has the stock trading symbol.
    Column F has the net amount of the transaction on that line.

    I want to populate Columns I & J, where I & J are the total Buy and Sell cost for each stock listed in Column H.

    So, for example I need to calculate the total "Net Amount" of "Buy" transactions for Stock ABC, and put it in Cell I2. I also need to put the the total "Net Amount" of "Sell" transactions for Stock ABC, and put it in Cell J2.

    I'm sure that looking at the attached sample EXCEL workbook, will make it clearer than all my verbiage.

    So, conceptually, I need to evaluate Columns B, C and F and put the sum of transactions in Cell I2 for those cases with "Buy" in Column B AND "ABC" in Column C.

    If there is no syntax for a double conditional in SUMIF, then I'd be happy with any formula for Cell I2 that accomplished the tax.

    I'm not terribly familiar with array formulas, but have used them on occasion if that's what's required to emulate a double conditional in SUMIF.

    Thanks in advance for any help you can give,
    metsci
    Attached Files Attached Files
    Last edited by metsci; 03-09-2014 at 07:36 PM. Reason: Mark as SOLVED

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,411

    Re: Double Conditional in SUMIF

    In 2003:

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Double Conditional in SUMIF

    Hi,

    If you do only have Excel 2003 then you'll have to fall back on the old SUMPRODUCT() function. i.e. in I2 copied down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and similarly in J2 changing "BUY" to "Sell"

    If you do however have Excel 2007 or later then use SUMIFS()
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    01-20-2013
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: Double Conditional in SUMIF

    Richard Buttrey,

    Mega-mega thanks!

    Your EXCEL 2003 suggestion really does a nice job.

    As an aside:
    I have EXCEL 2003 and EXCEL 2013, but use EXCEL 2003 about 95% of the time because it's so much easier to use and because I can then give workbooks to friends who only have EXCEL 2003.

    I tried the SUMFS() function in EXCEL 2013 and, of course, it works also. I like the SUMIFS() better because it seems more logical and easier to follow.
    The multiplication (*) operator used in the EXCEL 2003 solution is confusing to me (but it works great).

    As a second aside:
    If I use the SUMIFS() function in EXCEL 2003, it does not work and returns "#NAME?" in he cell.

    But, if I use the SUMIFS() function in EXCEL 2013, save it from there as an EXCEL 2003 ".xls" file and then open it in EXCEL 2003, it now works there.

    It appears to do this because it somehow automatically changes the "SUMIFS()" function to "_xlfn.SUMIFS()".

    So maybe I can have the best of both worlds by composing in EXCEL 2013 when I am in desperately in need of the SUMIFS() function, and then saving it as an EXCEL 2003 ".xls" file when I either want the convenience of EXCEL 2003 or want to give it to a friend who only has EXCEL 2003.

    Thanks again,
    metsci

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Double Conditional in SUMIF

    "_xlfn.SUMIFS()" just lets you know its there if you select that cell and hit enter it will change to #NAME? and will not calculate
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  6. #6
    Registered User
    Join Date
    01-20-2013
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: Double Conditional in SUMIF

    Yes!!!

    Thanks.

    It happened, so I better stick with the EXCEL 2003 solution.

  7. #7
    Registered User
    Join Date
    01-20-2013
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: Double Conditional in SUMIF

    Thanks.

    This works in EXCEL 2003

    It's hard for me to understand the syntax, but it works.

    NOTE: you have a minor typo. In my sample file the "$E" has to be "$F", but then it's fine.

    Thanks again,
    metsci

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,411

    Re: Double Conditional in SUMIF

    It's hard for me to understand the syntax, but it works.
    Does that refer to my formula? With regard to the typo, I just picked up the first value field ... missed the reference to column F.

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    It's essentially the same formula as Richard's. However, you can separate the components using commas, instead of asterisks. If you use commas, you need to coerce the TRUE/FALSE values to 1/0 ... which is what the double negative (--) does. The LOWER ensures that the comparison with the entries in column B matches lower case with lower case "buy". Shouldn't be an issue but some comparisons can be case sensitive ... so, belt and braces

    You would do well to define your data in terms of Named Ranges to make the references more straightforward and avoid the necessity to edit them. Oh, and beware, you cannot use whole column references in SUMPRODUCT formulae in Excel 2003 ... and you shouldn't in any other version.

    Regards, TMS

  9. #9
    Registered User
    Join Date
    01-20-2013
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: Double Conditional in SUMIF

    TMS,

    Thanks for the additional insight.

    Thanks also for your patience with a "newbie".

    metsci

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,411

    Re: Double Conditional in SUMIF

    No problem.

+ 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. Double Sumif
    By doowop5000 in forum Excel General
    Replies: 1
    Last Post: 07-17-2009, 07:10 AM
  2. Double SUMIF
    By J&SPriest in forum Excel General
    Replies: 4
    Last Post: 07-08-2009, 04:15 AM
  3. Double SUMIF
    By garethgtt in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-25-2007, 12:00 PM
  4. [SOLVED] Why does a sumif use double speech marks
    By owl37 in forum Excel General
    Replies: 1
    Last Post: 11-24-2005, 10:00 PM
  5. Sumif - double columns
    By Mats W. in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-27-2005, 12: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