Google-sheets – How to get the name of the row which is the mode in Google Spreadsheets

google sheets

Example:

  A    B
1 john 6
2 ryan 5
3 kate 8
4 paul 1

I want the formula that returns the text "kate" in A3, because the value in B3 is the highest in the range B1:B4. I would like to know also the same opperation but with the lowest value (i.e. B4 is the lowest, so I would get "paul").

Best Answer

For the highest value you can use:

=INDEX(sort(A:B, 2, false), 1, 1)

This first sorts and then retrieves the value from the first row and column of the sorted data.

Using the opposite sort order in the formula will yield the lowest value:

=INDEX(sort(A:B, 2, true), 1, 1)