+ Reply to Thread
Results 1 to 9 of 9

How to sum up only non-repeating values?

  1. #1
    Registered User
    Join Date
    07-30-2009
    Location
    Lithuania
    MS-Off Ver
    Excel 2002
    Posts
    8

    Question How to sum up only non-repeating values?

    I have data of the following structure:

    A 100
    A 100
    A 100
    B 5
    B 5
    B 2
    C 55

    I need to get

    A 100
    B 7
    C 55

    Meaning that the formula would check for all values in second column which have the same value in first column and them sum up only the ones that don't repeat within this range.

    For example in data range with A in first column we have 100, 100 and 100. It is repeating therefore formula takes 100 only once. It produces A 100. For B there are values 5, 5 and 2. 5 gets lost, system provides 7 for B. Etc...

    Any ideas how I can make it? There are lots of different values for A, B, C in my real data. Could be 50 different values, could be a hundred.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to sum up only non-repeating values?

    Not really clear what you're trying to do in truth, are you condensing the data or producing an aggregate analysis ?

    Assume your sample data were present in range A1:B7 and your values A,B,C in D1:D3 with results to go into E1:E3 ... a simple approach:

    C1: =A1&":"&B1
    copied down to C7

    Results

    E1: =SUMPRODUCT(--($A$1:$A$7=$D1),1/COUNTIF($C$1:$C$7,$C$1:$C$7&""),$B$1:$B$7)

  3. #3
    Registered User
    Join Date
    07-30-2009
    Location
    Lithuania
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: How to sum up only non-repeating values?

    Quote Originally Posted by DonkeyOte View Post
    Not really clear what you're trying to do in truth, are you condensing the data or producing an aggregate analysis ?
    Actualy I am condensing data.

    But the problem I have is that in some cases data I have is repeating. Therefore repeating values should be excluded from subtotals.

    I am going to analyse what you are offering now.

  4. #4
    Registered User
    Join Date
    07-30-2009
    Location
    Lithuania
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: How to sum up only non-repeating values?

    Quote Originally Posted by DonkeyOte View Post
    Assume your sample data were present in range A1:B7 and your values A,B,C in D1:D3 with results to go into E1:E3 ... a simple approach:
    Let's say my data looks this way:

    \1

    How the formula look then?

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to sum up only non-repeating values?

    I believe I provided the formulae (and references) in post #2, no ?

    On an aside it is better generally to post sample workbooks as opposed to images.

  6. #6
    Registered User
    Join Date
    07-30-2009
    Location
    Lithuania
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: How to sum up only non-repeating values?

    Quote Originally Posted by DonkeyOte View Post
    I believe I provided the formulae (and references) in post #2, no ?

    On an aside it is better generally to post sample workbooks as opposed to images.
    Yes you did. And thank you for that. But you distributed data in other cells and I guess the formula would be different then. If you would figure out the way you distributed data or the way this formula works I would't ask, you know...

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to sum up only non-repeating values?

    In all honesty, I don't know what you're asking I'm afraid...

    Are you saying you want to delete duplicate rows altogether at source ?
    Assuming you do you need to specify one other key fact, is the data sorted by Column A (ie all A's are listed consecutively and so on and so forth through B, C etc...)
    Last edited by DonkeyOte; 07-30-2009 at 08:42 AM.

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

    Re: How to sum up only non-repeating values?

    donkeyote this seems to work but i cant work out why freq always gives one more element in array so you have to extend sum and other qualifying range by 1
    =SUMPRODUCT(--(FREQUENCY(B1:B6,B1:B6)>0),--(A1:A7="b"),B1:B7)
    where data is in a1:b6
    Last edited by martindwilson; 07-30-2009 at 09:24 AM.
    "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

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to sum up only non-repeating values?

    Hi Martin, the Help file on Frequency function explains this (ie returned array > bins array), I don't use Frequency much myself so I wouldn't feel well placed to condone/condemn it's use in this context.

+ 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