简体   繁体   中英

In Excel, search one column for highest value that exists that is linked to another column

I'm not sure of the best wording for what I am trying to do which is why my title is a bit messy. Essentially I have a growing list of entries in 2 columns. In Column one is a number that represents an individual car. That entry is linked with the next column over that is the value of the cars current mileage. Every day the mileage is measured and a new entry in both columns is made. How do you print out the value that searches Column 2 for the highest mileage entry for an indivudal car number in column one?

Car     Miles
2       10.0
3       30.0
2       40.0
4       60.0

So for example, what formula would be required to spit out that the highest entry for Car 2 was 40 miles? I have tried variations of IF/S etc but just can't quite get it to consider both columns. Cheers

With Office 365 Excel:

=MAXIFS(B:B,A:A,"2")

With 2010 or later:

=AGGREGATE(14,6,B1:B5/(A1:A5=2),1)

With older an array formula:

=MAX(IF(A1:A5=2,B1:B5))

Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

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