简体   繁体   中英

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.

use:

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

Should be doable directly within a query as well:

=query(A:B,"select A,max(B) where A is not null group by A")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM