# Print text associated with a value

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?

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).

data

result

## Example

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

Question shows OP is not expecting ties but since these are often a possibility a slightly 'safer' query might be:

``````=QUERY(A1:B7, "SELECT A, B where B>="&large(B:B,3)&" ORDER BY B desc, A")
``````

This may output more than three results.