+ Reply to Thread
Results 1 to 18 of 18

ID lookup for Max Value in a given 'category'

Hybrid View

thisisntwally ID lookup for Max Value in a... 12-07-2012, 04:07 PM
Legend Rubber Re: ID lookup for Max Value... 12-07-2012, 04:17 PM
thisisntwally Re: ID lookup for Max Value... 12-07-2012, 04:21 PM
ChemistB Re: ID lookup for Max Value... 12-07-2012, 04:22 PM
thisisntwally Re: ID lookup for Max Value... 12-07-2012, 04:26 PM
ChemistB Re: ID lookup for Max Value... 12-07-2012, 04:28 PM
thisisntwally Re: ID lookup for Max Value... 12-07-2012, 04:32 PM
thisisntwally Re: ID lookup for Max Value... 12-07-2012, 04:36 PM
ChemistB Re: ID lookup for Max Value... 12-07-2012, 04:39 PM
thisisntwally Re: ID lookup for Max Value... 12-07-2012, 04:42 PM
Teethless mama Re: ID lookup for Max Value... 12-07-2012, 05:00 PM
ChemistB Re: ID lookup for Max Value... 12-07-2012, 05:01 PM
thisisntwally Re: ID lookup for Max Value... 12-07-2012, 05:07 PM
thisisntwally Re: ID lookup for Max Value... 12-07-2012, 05:22 PM
ChemistB Re: ID lookup for Max Value... 12-07-2012, 05:27 PM
thisisntwally Re: ID lookup for Max Value... 12-07-2012, 05:59 PM
Marcol Re: ID lookup for Max Value... 12-07-2012, 05:02 PM
ChemistB Re: ID lookup for Max Value... 12-07-2012, 05:24 PM
  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    9

    Question ID lookup for Max Value in a given 'category'

    Hi,

    I am struggling to get this Index/Match/Large function to run as expected. It keeps pulling the wrong output, and I am struggling to figure out what is driving the error.

    Could anyone take a look and tell my why I am an idiot?

    THANKS!

  2. #2
    Forum Contributor Legend Rubber's Avatar
    Join Date
    09-21-2012
    Location
    Tillsonburg, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    392

    Re: ID lookup for Max Value in a given 'category'

    what are you trying to do?

  3. #3
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: ID lookup for Max Value in a given 'category'

    look up the ID, within each category, that has the highest value. I've tried swapping in Large for Max, and I get the same results (ID of 101 for 2nd category, when it should be 105, and the formula working fine for the other 3)

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: ID lookup for Max Value in a given 'category'

    Yes,
    When you do MAX(($B$20:$B$34=G29)*($C$20:$C$34),0)
    you'll get
    MAX(1*1, 1*2, 1*3, 0) (from rows 24,25,26) which results in 3
    MATCH(MAX(($B$20:$B$34=G29)*($C$20:$C$34),0),$C$20:$C$34,0)
    Simplifes to MATCH(3,$C$20:$C$34,0)
    and the first 3 that Excel encounters in Col C is in row 22 which equates to "101"

    Next will figure out how to get the correct result
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: ID lookup for Max Value in a given 'category'

    Quote Originally Posted by ChemistB View Post
    Yes,
    When you do MAX(($B$20:$B$34=G29)*($C$20:$C$34),0)
    you'll get
    MAX(1*1, 1*2, 1*3, 0) (from rows 24,25,26) which results in 3
    MATCH(MAX(($B$20:$B$34=G29)*($C$20:$C$34),0),$C$20:$C$34,0)
    Simplifes to MATCH(3,$C$20:$C$34,0)
    and the first 3 that Excel encounters in Col C is in row 22 which equates to "101"

    Next will figure out how to get the correct result
    ah I see! I was thinking the problem might have been something like that, but obviously failed to follow the tracks effectively...

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: ID lookup for Max Value in a given 'category'

    Arrayed function
    In H10 dragged down

    =INDEX($A$2:$A$16,LARGE(IF($B$2:$B$16=G10,ROW($B$2:$B$16)-1,0),1))

    In H28
    =INDEX($A$20:$A$34,LARGE(IF($B$20:$B$34=G28,ROW($B$20:$B$34)-19,0),1))
    Does that work for you?

  7. #7
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: ID lookup for Max Value in a given 'category'

    Quote Originally Posted by ChemistB View Post
    Arrayed function
    In H10 dragged down

    =INDEX($A$2:$A$16,LARGE(IF($B$2:$B$16=G10,ROW($B$2:$B$16)-1,0),1))

    In H28
    =INDEX($A$20:$A$34,LARGE(IF($B$20:$B$34=G28,ROW($B$20:$B$34)-19,0),1))
    Does that work for you?
    It does! Now I need to parse what you're doing there...

    THANKS!!

  8. #8
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: ID lookup for Max Value in a given 'category'

    Oh blarg, it breaks if ID is text. Which it is in real life. Example fail.

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: ID lookup for Max Value in a given 'category'

    It shouldn't break if ID is text. Upload an example with it not working, please.

  10. #10
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: ID lookup for Max Value in a given 'category'

    Quote Originally Posted by ChemistB View Post
    It shouldn't break if ID is text. Upload an example with it not working, please.
    it's only breaking when ID is Text & Category is #

  11. #11
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: ID lookup for Max Value in a given 'category'

    In H29: =INDEX(A$20:A$34,MATCH(1,(C$20:C$34=MAX(($B$20:$B$34=G29)*($C$20:$C$34),0))*(B$20:B$34=G29),0))

    ctrl+shift+enter, not just enter

  12. #12
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: ID lookup for Max Value in a given 'category'

    You did not enter your second set as an array and your spreadsheet is set to Manual calculation so you will need to hit F9 to have it calculate the correct results. Does that help?

  13. #13
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: ID lookup for Max Value in a given 'category'

    @chemistB

    Perfect - Thanks!

    Can you explain what you're doing with the if/row element? I am not grasping how you are referencing the largest Value.

  14. #14
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: ID lookup for Max Value in a given 'category'

    Quote Originally Posted by thisisntwally View Post
    @chemistB

    Perfect - Thanks!

    Can you explain what you're doing with the if/row element? I am not grasping how you are referencing the largest Value.
    Ah, so is the relient upon the Value column being sorted ascending?

  15. #15
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: ID lookup for Max Value in a given 'category'

    Yes it is. I never compare anything to column C. If it is not going up then this becomes a bit more complex but is also doable.
    Check mama's and Marcol's solutions. They reference Col C in their formulas.

  16. #16
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: ID lookup for Max Value in a given 'category'

    Quote Originally Posted by ChemistB View Post
    Yes it is. I never compare anything to column C. If it is not going up then this becomes a bit more complex but is also doable.
    Check mama's and Marcol's solutions. They reference Col C in their formulas.
    Your solution is elegant as hell, but yeah, i need to make sure we're referencing cell.

    Mama & Marcol, you're on deck

  17. #17
    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: ID lookup for Max Value in a given 'category'

    See if this workbook helps (non CSE formulae)

    In H10
    Formula: copy to clipboard
    =INDEX($A$2:$A$16,MATCH(MAX(INDEX(($B$2:$B$16=G10)*($C$2:$C$16),,1)),INDEX(($B$2:$B$16=G10)*($C$2:$C$16),,1),0))

    In H29
    Formula: copy to clipboard
    =INDEX($A$20:$A$34,MATCH(MAX(INDEX(($B$20:$B$34=G28)*($C$20:$C$34),,1)),INDEX(($B$20:$B$34=G28)*($C$20:$C$34),,1),0))
    Attached Files Attached Files
    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.

  18. #18
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: ID lookup for Max Value in a given 'category'

    LARGE(IF($B$2:$B$16=G11,ROW($B$2:$B$16)-1,0),1)

    Okay, what we're doing here is creating a subarray from the larger array of B2:B16, remember this has to return the relative row for the INDEX to locate the matching value in Col A.
    IF(B2:B16=G11, ROW(B2:B16)-1,0) will return 0 if the value in B doesn't match the value in G10. If it does match it returns that row # -1 (we subtract 1 because we want a relative row number and this series starts in B2. Note in the second series which starts at B20, we subtract 19)

    So, with your data Excel comes up with this array (in H11 for example)
    {0,0,0,0,5,6,7,0,0,0,0,0,0,0} first match is in row 6 (minus 1 = 5) and so on

    Then we have LARGE({0,0,0,0,5,6,7,0,0,0,0,0,0,0}, 1) the final 1 says find the largest number so that number is 7

    =INDEX($A$2:$A$16, 7) which yields the value in A8
    Clear as mud?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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