Conditional Min and Max in Excel 2010

前端 未结 5 522
情书的邮戳
情书的邮戳 2020-12-06 13:13

\"enter

I would like to find Min and Max of Quantity (Column 2) based on Type (coloumn

相关标签:
5条回答
  • 2020-12-06 13:44

    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

    0 讨论(0)
  • 2020-12-06 13:52

    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:

    0 讨论(0)
  • 2020-12-06 14:01

    I would suggest to use =large(if(...=...;...);k) to solve that problem.

    0 讨论(0)
  • 2020-12-06 14:03

    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.

    0 讨论(0)
  • 2020-12-06 14:05

    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!

    0 讨论(0)
提交回复
热议问题