+ Reply to Thread
Results 1 to 12 of 12

Add highest values with the same basis

  1. #1
    Registered User
    Join Date
    06-06-2012
    Location
    Switzerland
    MS-Off Ver
    MS Excel 365
    Posts
    68

    Add highest values with the same basis

    Dear all,

    I have a very delicious issue! Please see attached Excel screenshot. I need to find the two highest values, but that would be too easy at this stage. Insofar, I need to find the two highest values with the same basis. Here is the difference, what I mean:

    The two highest values are: 35.00 (Porsche) and 40.00 (Audi) = Result 75.00 – but this is not what I am looking for…
    The two highest values with the same basis: 40.00 (Audi) and 30.00 (Audi) = Result 70.00 – this is what I want…!!!

    Now, to make the issue a little bit more difficult, it is not permitted to use an additional column for extra calculations, nor to use the words "Porsche", "Audi", etc. (because these parameters are finally unknown).

    So it should be a pure formula, e.g. =SUMPRODUCT(LARGE(B2:B11;ROW(1:2))*1)BUT(WITH SAME BASIS AS IN COLUMN A)

    Many thanks for your efforts on this.

    Best regards,
    FixandFoxi (yes, I am)
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Add highest values with the same basis

    So you want to find the sum of the two numbers that have the highest sum, given that they have the same basis?
    Sincerely
    S?ren Larsen

    "Give a man a fish, and you'll feed him for a day. Give a man a fishing rod, and he'll steal your yacht!"

  3. #3
    Registered User
    Join Date
    06-06-2012
    Location
    Switzerland
    MS-Off Ver
    MS Excel 365
    Posts
    68

    Re: Add highest values with the same basis

    Basically yes, it is important that they have the same basis. In the final version, I have to find "the 10 highest values" out of 10'000 entries...

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Add highest values with the same basis

    In helper column you can write:

    =SUM(LARGE(IF($A$2:$A$100=$A2;$B$2:$B$100);{1;2}))
    (comfirmed with ctrl+shift+enter)

    And then use MAX value from this column
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Add highest values with the same basis

    Are you sure this can be done with one formula in one cell with the data provided?

    You would first have to find the 2 highest values for each carmodel, and then test which sum of these pairs is the highest.

  6. #6
    Registered User
    Join Date
    06-06-2012
    Location
    Switzerland
    MS-Off Ver
    MS Excel 365
    Posts
    68

    Re: Add highest values with the same basis

    @ zbor: thanks for this, but any chance to do this without any helper column?
    @ Soren: quite sure...

  7. #7
    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: Add highest values with the same basis

    Try this ...

    In D2
    Please Login or Register  to view this content.
    Drag/Fill Down

    In E2 this array formula
    Please Login or Register  to view this content.
    Confirm with Ctrl+Shift+Enter not just Enter
    Drag/Fill Down

    Then use C/F to highlight the highest pair(s)
    Attached Files Attached Files
    Last edited by Marcol; 06-06-2012 at 07:40 AM. Reason: Added C/F to solution
    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.

  8. #8
    Registered User
    Join Date
    06-06-2012
    Location
    Switzerland
    MS-Off Ver
    MS Excel 365
    Posts
    68

    Re: Add highest values with the same basis

    Hi Marcol

    Interesting approach... will try this on the large file! Can you please give me some additional information iro "REPT("Z";255);CHOOSE({1;2}"... I do not understand this term. Why? Thanks!

  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Add highest values with the same basis

    Personally I'd use a helper column or columns as suggested.......but it is possible with a single formula, for example with "basis" in A2:A100 and costs in B2:B100 this formula will give you the maximum sum of the top 5 of each basis

    =MAX(MMULT((TRANSPOSE(A2:A100)=A2:A100)+0,B2:B100*(COUNTIFS(A2:A100,A2:A100,B2:B100,">"&B2:B100)+ COUNTIFS(OFFSET(A2,,,ROW(A2:A100)-ROW(A2)+1),A2:A100, OFFSET(B2,,,ROW(B2:B100)-ROW(B2)+1),B2:B100)<=5)))

    confirmed with CTRL+SHIFT+ENTER

    change the 5 as required

    Note that if any basis has fewer than 5 entries then all of those entries will be summed and that could possibly be the max value (for example if the top 4 Porsche values summed to higher than the top 5 of any other type)
    Audere est facere

  10. #10
    Registered User
    Join Date
    06-06-2012
    Location
    Switzerland
    MS-Off Ver
    MS Excel 365
    Posts
    68

    Re: Add highest values with the same basis

    Hi daddylonglegs, can you please upload the Excel sheet with the formula, I can not use the above one, seems to be an error somewhere (yes, I finalised with CTRL+SHIFT+ENTER :-)! Thanks!

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Add highest values with the same basis

    OK the attached has a randomly generated list of car types in A2:A100 and costs in B2:B100 and the formula in F2 gives the max value for the top n where n is in F1 (also randomly generated). That formula only uses columns A and B

    As a check I added in a helper column along the lines suggested by zbor and the formula in F3 calculates the same thing using the MAX of that column. You should see the same answer in both F2 and F3. Press F9 to generate different random values
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    06-06-2012
    Location
    Switzerland
    MS-Off Ver
    MS Excel 365
    Posts
    68

    Re: Add highest values with the same basis

    Special thanks to all of you (especially Marcol and daddylonglegs, they gave me the final solution/approach)! Simply brilliant...

+ 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