I would like to find Min and Max of Quantity (Column 2) based on Type (coloumn
A rather sneaky but simple way to do it is
1. create a new column that concatenates both Type and Qty and Call it "TypeQty" or whatever you'd like
2. Sort (Ascending) the new table ie Type,Qty and TypeQty all together but sort on the TypeQty column.
3. apply a formulat that checks if the type in the row above is the same as the current row. if not then mark that row because its the last of the current type.
you will end up with the "mark" only the max rows for each type. See screenshots
This works without ctrl+shift+enter, but your table should be sorted by a TYPE column.
Let's assume that your table is placed in B3:C15, then in A4 put
=IF(B4=B3;A3;A3+1)
in E4 - "1", in E5 - "2" , in E6 - "3", in F4 put:
=MAX(INDIRECT("C" & MATCH(E4;$A$1:$A$17;0) & ":C" & MATCH(E4;$A$1:$A$17;1) ))
and copy it to F5 and F6
in G4 put:
=MIN(INDIRECT("C" & MATCH(E4;$A$1:$A$17;0) & ":C" & MATCH(E4;$A$1:$A$17;1) ))
and copy it to G5 and G6
MATCH function handles strings incorrectly, so I had to number TYPEs, you can use VLOOKUP to change numbers in column E to a strings
In my table I used this solution to find strings with maximum values this way:
I would suggest to use =large(if(...=...;...);k)
to solve that problem.
Anything other than a PivotTable (as suggested by @andy holaday) seems sheer masochism (unless for a very good but presumably very peculiar reason):
Note that for illustration I doubled the OP's data quantities for B
and these again for C
.
Assuming your data above is in A2:B13, this works:
=MAX(IF(A2:A13="A",1,0)*(B2:B13))
=MAX(IF(A2:A13="B",1,0)*(B2:B13))
=MAX(IF(A2:A13="C",1,0)*(B2:B13))
You have to press ctrl+shft+Enter when you enter the formula into a cell. This finds all rows with the A
, B
, or C
, and multiplies 1
with the value next to it if the letter matches your formula, and 0
if it doesn't match. Then you take the MAX()
of the values.
<<< Edit >>>
As @GSerg suggested, you can also do it with these formulas, if you press ctrl+shft+Enter when entering them into each cell:
=MAX(IF(A:A="A",B:B))
=MAX(IF(A:A="B",B:B))
=MAX(IF(A:A="C",B:B))
A much more elegant way of doing it!