Search code examples
arrayssortinggoogle-sheetsmaxgoogle-query-language

How to get max values for each unique value in a different column in Google Sheets?


I have two columns, the first column (A) has names and the second column (B) has values.

A B
apple 10
orange 12
orange 14
apple 8

Is there a way to get only rows with unique names from A AND max values from B? So the result should look like this:

A B
apple 10
orange 14

I tried using different combinations of FILTER, QUERY and UNIQUE, but so far no luck. Note that the actual dataset I'm using is much larger than this, but the idea is the same.


Solution

  • use:

    =SORTN(SORT(A:B; 2; 0); 9^9; 2; 1; 1)