+ Reply to Thread
Results 1 to 8 of 8

Find top 4 values in column A, sum adjacent value in B, take only highest duplicate

  1. #1
    Registered User
    Join Date
    05-27-2014
    Posts
    2

    Find top 4 values in column A, sum adjacent value in B, take only highest duplicate

    I have two columns, A & B. I want the top 4 values in column A, then I want to sum their adjacent values in column B. Also, columns need to remain unsorted.

    If there are duplicates in column A that make up the top 4, take the one with the highest value in column B.

    Example:
    A B
    1 | 22
    4 | 2
    5 | 6
    2 | 11
    3 | 10
    4 | 80


    Top 4 values from column A: 5,4,3,2. The values it should sum up should be 6+80+10+11.

    Tried using helper columns to find the max but don't know how to get it to only pick up the highest duplicate.

    EDIT: List is dynamic. Ideally, the engineer can cut and paste their values in columns A & B but will be able to get their total from a single cell.
    Last edited by montney1001; 05-27-2014 at 01:36 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Find top 4 values in column A, sum adjacent value in B, take only highest duplicate

    sorry changed post
    Last edited by nathansav; 05-27-2014 at 01:20 PM.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Find top 4 values in column A, sum adjacent value in B, take only highest duplicate

    =SUM(IF(A1:A10>=LARGE(A1:A10,4),B1:B10))

    Shift ctrl and enter for this formula, i'll need to check the max bit

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Find top 4 values in column A, sum adjacent value in B, take only highest duplicate

    Quote Originally Posted by nathansav View Post
    =SUM(IF(A1:A10>=LARGE(A1:A10,4),B1:B10))

    Shift ctrl and enter for this formula
    How does this account for the duplicate entries and ensuring the higher value in column B is used?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    05-27-2014
    Posts
    2

    Re: Find top 4 values in column A, sum adjacent value in B, take only highest duplicate

    Thanks for this suggestion!

    I tried this but I got a total of 98 but I should be getting 107

  6. #6
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Find top 4 values in column A, sum adjacent value in B, take only highest duplicate

    I am just looking at that bit

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find top 4 values in column A, sum adjacent value in B, take only highest duplicate

    Hi,

    Try this array formula**:

    =SUM(INDEX(B1:B6,N(IF(1,ROUND(MOD(LARGE(IF(COUNTIFS(A1:A6,A1:A6,B1:B6,">"&B1:B6)=0,A1:A6+ROW(A1:A6)/10^9),{1,2,3,4}),1)*10^9,1)))))


    though you don't say what should be the result if there are less than 4 unique values in column A: since you are in effect discarding all but that with the largest value for each group, the following scenario, for example, would error, since there are only three 'largest' values according to your criteria:

    1
    22
    4
    2
    2
    6
    2
    11
    2
    10
    4
    80

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  8. #8
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Find top 4 values in column A, sum adjacent value in B, take only highest duplicate

    @mountney1001

    I was thinking at a pivot table solution.

    Advice:

    If you add an excel file, without confidential information, forummembers can test the given code in your file, without building the sheet themselves.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Re: Find lowest 5 numbers in column A with highest values in column B
    By jd16 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-05-2013, 02:08 AM
  2. Replies: 4
    Last Post: 10-06-2013, 10:40 AM
  3. Find lowest 5 numbers in column A with highest values in column B
    By dmccoy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-06-2013, 09:22 AM
  4. [SOLVED] Need Urgent help on Adjacent values of Duplicate column values should be be in single row.
    By anto_01 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2012, 09:55 PM
  5. Replies: 2
    Last Post: 03-28-2012, 11:47 AM

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