Google-sheets – Print text associated with a value

google sheets

I have a Google Sheet that collects data and analyses any trends.
What I'm trying to do is figure out how to output the text value associated with the numerical value.

Example:

Apples      7
Oranges     2
Pears       0
Mangoes     4

I grab the highest values by doing the following..

= LARGE(B:B, 1)
= LARGE(B:B, 2)
= LARGE(B:B, 3)

My desired output would look like..

Top 3
-------
Apples 7
Mangoes 4
Oranges 2

Which then changes dynamically according to the data values in column B.

But how do I then output the text value associated with this?

Best Answer

With the following formula you can accomplish that.

Formula

=QUERY(DATA!A1:B4, "SELECT A, B ORDER BY B DESC LIMIT 3")

Explained

The QUERY formula selects the two columns and orders them descendingly according to column B. Then it limits the result to three rows (top 3).

Screenshot

data
enter image description here

result
enter image description here

Example

I've created an example file for you: Top 3 results