I have two columns in Excel as follows:
col1 col2
1 10
1 22
1 11
1 23
1 14
2 16
2 12
2 10
2 9
How do I write a command to returns the maximum value from col2
corresponding to each unique value in col1
?
So here I need to write a command to get 23
and 16
.
The data I have shown here are dummies; I have 600 unique values in col1
in my actual data set.
Since the left hand values seem to be in order, Subtotal should work.
Even if a solution has been found. I think it is too complicated and oversized to use the pivot for this and it might not be possible in all scenarios. Here is one that can be found searching the internet for "max if excel" (e.g. see here; adapted)
{=MAX(IF(A:A=A1,B:B))}
Attention! This is an array formula, you have to enter it without the curly brackets and then press Ctrl+Shift+Enter to submit the formula.
Pivot tables: the single most underutilized and powerful feature of excel.
Step by Step:
The pivot table will find the max value in row 2 for each unique value in row 1 which is what I believe you are after.