+ Reply to Thread
Results 1 to 5 of 5

sum only one instance of duplicate

  1. #1
    Registered User
    Join Date
    01-23-2009
    Location
    Adelaide
    MS-Off Ver
    Excel 2016
    Posts
    30

    sum only one instance of duplicate

    Hi All

    I am after a formula (preferably subtotal), whereby I can sum only one instance of a duplicate. From the below data for eg, I want to return a sum value of 110 for R1087 and not 220.

    Cheers



    R1087 110
    R1087 110
    R1086 710
    R1086 710
    R1086 710
    R1086 710
    R1045 600
    R1045 600

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

    Re: sum only one instance of duplicate

    Is the relationship between code and value 1:1 as implied in the sample dataset ?
    (ie all instances of R1087 will be 110)

    If so, calculate the Average (ie SUMIF / COUNTIF) or just conduct a VLOOKUP to return first value for given code.

  3. #3
    Registered User
    Join Date
    01-23-2009
    Location
    Adelaide
    MS-Off Ver
    Excel 2016
    Posts
    30

    Re: sum only one instance of duplicate

    Thanks DonkeyOte, but Im afraid I have not explained it well. Please see example attached.

    There are a couple of conditions that I need to apply to get the right subtotal. Hope it makes sense!

    Cheers
    Attached Files Attached Files

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

    Re: sum only one instance of duplicate

    I confess I'm struggling to come up with something elegant for a single cell calculation (ie no helper cells)

    Using your sample the below should work:

    =SUMPRODUCT(--(A6:A12=A6:A12),--(MATCH(A6:A12&"@"&D6:D12,A6:A12&"@"&D6:D12,0)=(ROW(D6:D12)-ROW(D6)+1)),--(D6:D12=SUBTOTAL(4,OFFSET(D6:D12,MATCH(A6:A12,A6:A12,0)-1,0,COUNTIF(A6:A12,A6:A12),1))),D6:D12)

    however it's ugly, inefficient and volatile and there must be a better way.

    If you used helper calcs you could greatly simplify proceedings.

  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: sum only one instance of duplicate

    id probably go for a helper
    =IF(COUNTIF($A$6:A6,A6)>1,"",MAX(($A$6:$A$12=A6)*($D$6:$D$12)))
    array enterred then dragged down and summed
    "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

+ 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