+ Reply to Thread
Results 1 to 9 of 9

Sum unique values according to criteria (sumif unique values)

  1. #1
    Registered User
    Join Date
    07-07-2012
    Location
    Moving around
    MS-Off Ver
    Office 2003 & 2007
    Posts
    5

    Sum unique values according to criteria (sumif unique values)

    I am looking for a formula that given a condition in one column, sums all the unique values from another column.

    SUMIF only takes me half way, as I still need to sum the unique values. If I could invent functions, I guess I would be looking for something like:
    SUM.UNIQUE.IF(Range to look, Criteria, Range to sum unique values)

    Here's some example data:

    sumif_unique_values.xlsx

    Product GlobalSum
    PT1 2
    PT2 4
    PT1 2
    PT2 4
    PT3 4
    PT1 3
    PT2 5
    PT3 3
    PT1 3
    PT2 5
    PT1 3
    PT2 5

    Expected results from example data:
    Sum all unique values in column B (GlobalSum) for Product 1 (PT1) = 2+3 = 5
    Sum all unique values in column B (GlobalSum) for Product 2 (PT2)= 4+5 = 9

    I tried the solution on another post that seemed to describe my problem, but it didn't work… Here's the code sugested on that post:

    Please Login or Register  to view this content.

    Many thanks on advance for all your help.

    Cheers, hmpw

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Sum unique values according to criteria (sumif unique values)

    Hi hmpw and welcome to the forum,

    If you look at advanced filters there is a "unique" check box that will reduce your table to unique values. Then use your formula or perhaps a Pivot Table to get the attached answer.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Sum unique values according to criteria (sumif unique values)

    Alternatively, use a helper column..(Column 'C') of attached.
    Attached Files Attached Files
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Sum unique values according to criteria (sumif unique values)

    Maybe a simpler helper column?

    I've used SUMPRODUCT() in this example, but using COUNTIFS()/SUMIFS() would be more efficient with 2007 and above.

    Maybe someone will convert this for you.

    [EDIT]
    Try in D2
    Please Login or Register  to view this content.
    and substitute the sumproduct in G2 with
    Please Login or Register  to view this content.
    I can't check this edit, I only have access to 2003 at the moment.
    Attached Files Attached Files
    Last edited by Marcol; 07-08-2012 at 05:31 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  5. #5
    Registered User
    Join Date
    07-07-2012
    Location
    Moving around
    MS-Off Ver
    Office 2003 & 2007
    Posts
    5

    Re: Sum unique values according to criteria (sumif unique values)

    Quote Originally Posted by MarvinP View Post
    Hi hmpw and welcome to the forum,

    If you look at advanced filters there is a "unique" check box that will reduce your table to unique values. Then use your formula or perhaps a Pivot Table to get the attached answer.
    Hi MarvinP,

    Thanks for welcome me to the forum and for your answer. Your suggestion does the trick, but I didn't mention in my original post that I need it to work for Excel 2003 and more importantly, I need it to work as a formula since it goes into at least 30 cells with that many product variations in a summary report table.

    Thanks anyway for your time and help.

    Cheers, hmpw

  6. #6
    Registered User
    Join Date
    07-07-2012
    Location
    Moving around
    MS-Off Ver
    Office 2003 & 2007
    Posts
    5

    Re: Sum unique values according to criteria (sumif unique values)

    Quote Originally Posted by Ace_XL View Post
    Alternatively, use a helper column..(Column 'C') of attached.
    Hi Ace_XL,

    Thanks for your answer. Your suggestion worked like a charm. Since I failed to mention that I need it to work for Excel 2003, I had to retrofit your solution for that version, i.e., change IFERROR for IF(ISERROR(... and COUNTIFS for SUMPRODUCT, resulting in a less elegant formula, but still equally functional.

    Thanks for your time and help.

    Cheers, hmpw

  7. #7
    Registered User
    Join Date
    07-07-2012
    Location
    Moving around
    MS-Off Ver
    Office 2003 & 2007
    Posts
    5

    Re: Sum unique values according to criteria (sumif unique values)

    Quote Originally Posted by Marcol View Post
    Maybe a simpler helper column?

    I've used SUMPRODUCT() in this example, but using COUNTIFS()/SUMIFS() would be more efficient with 2007 and above.

    Maybe someone will convert this for you.

    [EDIT]
    Try in D2
    Please Login or Register  to view this content.
    and substitute the sumproduct in G2 with
    Please Login or Register  to view this content.
    I can't check this edit, I only have access to 2003 at the moment.
    Hi Marcol,

    Thanks for your answer. Your suggestion works perfectly, but I opted for Ace_XL's solution as it needed one less helper column and I had to repeat this process in nine different places in my database. But I am still studying your formulas for general knowledge as it contains functions that I've never used before.

    Thanks for your time and help.

    Cheers, hmpw

  8. #8
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Sum unique values according to criteria (sumif unique values)

    methods without any helper column:

    if you are using 2007, see if this works in cell E15, just ENTER:

    Please Login or Register  to view this content.
    if using 2003, see if this works in cell E15, CTRL+SHFT+ENTER:

    Please Login or Register  to view this content.
    Last edited by icestationzbra; 07-14-2012 at 10:55 AM. Reason: methods for both versions of excel
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Sum unique values according to criteria (sumif unique values)

    Hmm?
    but I opted for Ace_XL's solution as it needed one less helper column
    The solution I offered only has one helper column! It will also work for all versions of Excel.
    The formula in Column F is only a way to get unique values from Column A, are you considering this a helper column?

    @ icestationzbra
    Array formulae are very clever but can be expensive in larger lists.
    Your solution is only reliable if the range calculated is the same size, or one row more, than the data list.
    If the user wants to allow some freeboard for varying sizes of data lists, then you will need to use Dynamic Named Ranges, or adjust the formula for each list.

    Clear Cells A12:B13 in this workbook to see what I mean.
    Attached Files Attached Files

+ 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