+ Reply to Thread
Results 1 to 6 of 6

Sum Positives and Absolute Value Negatives with Multiple Criteria

  1. #1
    Registered User
    Join Date
    10-20-2010
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Sum Positives and Absolute Value Negatives with Multiple Criteria

    I am trying to compose a formula that will sum positives and absolute value negatives, but only if the row they are in meets one of several criteria.

    For just totaling, I use =SUMPRODUCT(SUMIF(A1:A10,F1:F3,B1:B10)) where F1:F3 lists the preset criteria. Works great.

    I have tried using =SUMPRODUCT(ABS(SUMIF(A1:A5,F1:F3,B1:B5))); however, this calculates the sum of each array, then adds them as absolute values.

    How do a calculate the absolute value of the array first? Am I going about this wrong?

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Sum Positives and Absolute Value Negatives with Multiple Criteria

    Wouldn't the ABS() go around the B1:B5 ?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Sum Positives and Absolute Value Negatives with Multiple Criteria

    My bad, here, try this:

    =SUMPRODUCT(--ISNUMBER(MATCH(A1:A5, F1:F3, 0)), ABS(B1:B5))

  4. #4
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    365
    Posts
    2,243

    Re: Sum Positives and Absolute Value Negatives with Multiple Criteria

    Or, use SUMIFS,

    =SUMPRODUCT(SUMIFS(B1:B10,B1:B10,{">0","<0"},A1:A10,F1:F3)*{1,-1})
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  5. #5
    Registered User
    Join Date
    10-20-2010
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Sum Positives and Absolute Value Negatives with Multiple Criteria

    Thank you gentlemen. Both options work perfectly.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Sum Positives and Absolute Value Negatives with Multiple Criteria

    If that takes care of your need, please select Thread Tools from menu above and set this topic to SOLVED.

+ 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