+ Reply to Thread
Results 1 to 12 of 12

Max Functions

  1. #1
    Registered User
    Join Date
    02-11-2004
    Location
    Peoria, IL
    Posts
    7

    Max Functions

    Is there a way to return the row number of a matrix has the maximum or minimum value of that column? I'm not looking for the value, but the row number. I want to tie this value to a text string to display on my spreadsheet.
    Robert Weber, PE
    Maurer-Stutz, Inc.
    Peoria, IL
    309-693-7615
    www.maurerstutzinc.com

  2. #2
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    Robert: Try this (adjust range to meet your needs):

    =MATCH(MAX(K4:K21),K:K,0)

    HTH

    Bruce
    Bruce
    The older I get, the better I used to be.
    USA

  3. #3
    Registered User
    Join Date
    02-11-2004
    Location
    Peoria, IL
    Posts
    7
    Thanks, Bruce. This gets me going in the right direction. Unfortunately it only works for a 1-dimensional array and mine is 2-d. I think that I can make it work with a series of nested IFs, but that sounds tedious.

    Thanks again,

    Rob

    p.s. - Love your sig.

  4. #4
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    About my sig... a year ago I would have been able to discern that you had a 2D range...


    Bruce

  5. #5
    Registered User
    Join Date
    02-11-2004
    Location
    Peoria, IL
    Posts
    7

    How About This

    Ran into trouble with the nested IFs. I have 12 columns of data (one If for each column) and the limit for nesting is 7. How about this:

    I've given each column a name (month1, month2, etc.). I have created a cell that generates the correct array name in the cell from the given data. Is there a way to reference that cell in the Match function as an array name (and therefore reference the correct array) rather than simply the entry in that cell?

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996
    Please excuse me for jumping in here, but I think I might have something you can work with.

    Assuming you have a rectangular range of cells that contain numbers and you want to know the row numbers of the cells that contain the maximum and minumum values within that range, try these formulas:

    MaxValRow: =SUMPRODUCT(($A$1:$C$10=MAX($A$1:$C$10))*ROW($A$1:$C$10))

    MinValRow: =SUMPRODUCT(($A$1:$C$10=MIN($A$1:$C$10))*ROW($A$1:$C$10))


    I used the range A1:C10, but you can adjust the references to fit your situation.

    Does that help?

    Ron

  7. #7
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    Thanks for the suggestion, Ron. I figured it would be a SUMPRODUCT solution, but I am still trying to figure out that one!

    One note: If you have multiple MAX or MIN values, this will skew the result.

    e.g. if the MAX appears in row 2 and again in row 10, the result of the formula will be 12.

    Rob: Is this an issue for you (duplicate entries in your table)? If so, you could test for duplicates and indicate a failure by this:

    =IF(COUNTIF(K4:N21,MAX(K4:N21))>1,"FAIL",SUMPRODUCT((K4:N21=MAX(K4:N21))*ROW(K4:N21)))

    Bruce
    Last edited by swatsp0p; 04-28-2005 at 02:25 PM.

  8. #8
    Registered User
    Join Date
    02-11-2004
    Location
    Peoria, IL
    Posts
    7
    For all intents and purposes, the numbers in the table show a peak somewhere near the lower right-hand corner. Each row peaks towards the bottom and there is an overall peak around row 9 or 10. I am NOT looking for the absolute max, but rather the max in a user specified column.

    What I'm trying to do is allow the user to specifiy a condition (column), and have the spreadsheet return the max value in that column (tied to some other user inputs). Then I want the spreadsheet to return a text string that is unique for every entry in the array (I've set up a second array with the text string in it - therefore the requirement for the row number for the max value).

    Ron, by all means, jump in - and anyone else, the water's fine. I'll play with your suggestion, Ron, and see if it's workable for my situation.

    Rob

  9. #9
    Registered User
    Join Date
    02-11-2004
    Location
    Peoria, IL
    Posts
    7
    No, I'm getting a combined value of some sort.

    Is there anything with the call name/label possibility?

  10. #10
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996
    Well, given what we know so far, maybe you can work with a variation of this formula:
    MaxValRow:
    =SUMPRODUCT((OFFSET($A$1:$A$10,,?)=MAX(OFFSET($A$1:$A$10,,?)))*ROW(OFFSET($A$1:$A$10,,?)))

    MinValRow:
    =SUMPRODUCT((OFFSET($A$1:$A$10,,?)=MIN(OFFSET($A$1:$A$10,,?)))*ROW(OFFSET($A$1:$A$10,,?)))

    Note: the ? in the OFFSET function indicates how many columns to shift from A:A. Zero indicates use A1:A10, 3 indicates use D1:D10.

    Are heading in the right direction here?

    Ron

  11. #11
    Registered User
    Join Date
    02-11-2004
    Location
    Peoria, IL
    Posts
    7

    Smile I've Got It!

    I added the Match function to the bottom of each column. Then I used a nested hlookup to pull the text string I wanted from the secondary matrix.

    Thanks for all your help.

    Rob

  12. #12
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    Way to go Rob. I'm glad you got it figured out. Ron, thanks for bailing me out on this one...

    Bruce

+ 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