+ Reply to Thread
Results 1 to 10 of 10

Return row of max value of a category

Hybrid View

  1. #1
    Registered User
    Join Date
    02-24-2011
    Location
    Goteborg, Sweden
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    9

    Return row of max value of a category

    Hello All!

    Here is the problem:

    I want to output for each different customer, the MAX amount they bought and which item it was.

    Customer Item Amount
    AAA---------A-----20
    AAA---------B-----31
    BBB---------C-----10
    CCC---------D-----22
    DDD---------E-----66
    DDD---------F-----44
    DDD---------G-----97
    BBB---------H-----16

    ie.

    Customer Item Amount
    AAA---------B-----31
    BBB---------H-----16
    CCC---------D-----22
    DDD---------G-----97

    Thanks for your help!!!
    -Luis
    Attached Files Attached Files
    Last edited by Lukini; 11-22-2011 at 10:16 AM.

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Return row of max value of a category

    Array formulas try attachment
    Attached Files Attached Files
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    Forum Contributor
    Join Date
    01-28-2010
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2003
    Posts
    157

    Re: Return row of max value of a category

    If you sort by Customer ascending then by Amount descending VLOOKUP returns required values.

    Beau Nydal
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    02-24-2011
    Location
    Goteborg, Sweden
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    9

    Re: Return row of max value of a category

    Thanks for your reply!
    Thou It can be quite complicated when you have thousands "customer" values to sort. Do you know a more robust method?

    Thanks again!!
    -Luis

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Return row of max value of a category

    Hi

    For the maximum quantities per customer, I think definitely give you a solution.

    But to what Item is what gives this result, the solution you propose is similar to other members and requires the numbers are unique per customer.

    Take a look to the attached.....
    Attached Files Attached Files
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

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

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  6. #6
    Registered User
    Join Date
    02-24-2011
    Location
    Goteborg, Sweden
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    9

    Re: Return row of max value of a category

    Thanks for your help!

    I have checked the methods and as i can see Fotis1991 method is more robust and fool proof than beaunydal method. But beaunydal is super simple and clever, thats the one im using :D

    Thanks!!!
    -Luis

  7. #7
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Return row of max value of a category

    I am not sure that formula of beaunday is working (try to change cell C3 e.g to 50 and look at the result of formula)

  8. #8
    Registered User
    Join Date
    02-24-2011
    Location
    Goteborg, Sweden
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    9

    Re: Return row of max value of a category

    You are right, but as beaunday mentioned, the source data needs to be sorted first. if the data is updated, then the sorting needs to be done again so the output is updated. Tricky...

  9. #9
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Return row of max value of a category

    Sorting will not help
    Customer Item Amount Customer Item Max Amount
    AAA B 31 AAA B 31
    AAA A 55 BBB H 16
    BBB H 16 CCC D 22
    BBB C 10 DDD G 97
    CCC D 22
    DDD G 97
    DDD E 66
    DDD F 44
    the result should be AAA A 55 (and first column is sorted)

  10. #10
    Registered User
    Join Date
    02-24-2011
    Location
    Goteborg, Sweden
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    9

    Re: Return row of max value of a category

    I have tried again. Took the file from beaunday and changed C3 from 20 to 55. Then selected the whole C column and sorted from Z-->A (descending) and select -expand the selection-
    Then selected the whole A column and sorted A-->Z (ascending) and select -expand the selection.

    This updated the output with the correct Item and max amount for each customer.

    Maybe you did it in another way???

+ 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