Google-sheets – Google Sheets list key with highest value in key value pair

google sheetsworksheet-function

I have a some data in key-value pairs setup like so:


     A           B
1  Key:        Value:
2  Cars          5
3  Bikes         4
4  Vans          9
5  Trucks        6

What I can't seem to figure out (mind-block) is the formula to answer this:

Product with higest sales:    <answer should be 'Vans'>

What formula would I need to get the result Vans? I've tried this:

 =FILTER(A2:A6, MAX(B2:B6))

To which I get an error stating that the Fliter has mismatched array sizes.

Best Answer

You need to specify a condition, not just a value, for the FILTER function.

So:

=FILTER(A2:A6, B2:B6 = MAX(B2:B6))

I have set up a demonstration spreadsheet for this, feel free to have a look or copy it.