Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return row label for max value in excel r

Tags:

excel

How do I return the value in a column being used to label the rows of a table? For example, given the table below I want to find MAX(A:A) and return "Three" instead of the value 1.

        |A      B      C    D
--------|---------------------------------
One     |0.2    0.2   0.5   0.4
Two     |0.1    0.1   0.6   0.1
Three   |1.0    0.3   0.7   0.2
Four    |0.5    0.4   0.5   0.3

Assume if two values are the same then returning either is acceptable.

like image 442
mjm26 Avatar asked Jul 29 '13 16:07

mjm26


People also ask

How do I return the maximum number of rows?

To get the position of the maximum value in a range (i.e. a list, table, or row), you can use the MAX function together with the MATCH function. Which returns the number 4, representing the position in this list of the the most expensive property. The MAX function first extracts the maximum value from the range C3:C11.

How do you show the corresponding name to the highest value in Excel?

The MAX function in Excel returns the highest value in a set of data that you specify. The syntax is as follows: MAX(number1, [number2], …) Where number can be represented by a numeric value, array, named range, a reference to a cell or range containing numbers.


2 Answers

Assuming data in rows 1 to 4, put this in B5 to get the answer for column B:

=INDEX(A1:A4,MATCH(MAX(B1:B4),B1:B4,0))
like image 109
Doug Glancy Avatar answered Oct 19 '22 17:10

Doug Glancy


use the OFFSET and MATCH functions with MAX

OFFSET(A1,MATCH(MAX(A:A),A:A,0),0)

MATCH returns the position of a lookup value in the lookup array.

like image 20
user3794950 Avatar answered Oct 19 '22 19:10

user3794950