+ Reply to Thread
Results 1 to 3 of 3

MAX with IF Returns Unexpected Value

  1. #1
    Registered User
    Join Date
    03-31-2012
    Location
    KY
    MS-Off Ver
    Excel 2010
    Posts
    8

    MAX with IF Returns Unexpected Value

    Columns
    A: Name of the person
    E: Year
    F: Status
    J: Value to check


    I am attempting to find the largest value, based on several criteria. This formula always returns 0.
    =MAX(IF(AND($A$2:$A1500="Bob",$F$2:$F$1500="Active", OR($E$2:$E$1500="All",$E$2:$E$1500="2012")), $J$2:$J$1500, 0))


    If I remove the MAX and put the rest of the formula on each row, it returns the correct value for each row.
    =IF(AND(A2="Bob", F2="Active", OR(E2="All",E2="2012")), J2, 0)


    If I remove $A$2:$A1500="Bob" from the original formula, instead of 0, it returns the largest value in the list as if the IF statement wasn't there. The row with the maximum value in the last does not match any of the IF criteria.
    =MAX(IF(AND($F$2:$F$1500="Active", OR($E$2:$E$1500="All",$E$2:$E$1500="2012")), $J$2:$J$1500, 0))


    Any suggestions anyone can offer would be greatly appreciated.

    Thanks!

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695

    Re: MAX with IF Returns Unexpected Value

    You can use AND and OR with single values but that doesn't work with a range (or not as you expect, because OR and AND always return single values not an array) - try like this using * and + instead

    =MAX(IF(($A$2:$A1500="Bob")*($F$2:$F$1500="Active")*(($E$2:$E$1500="All")+($E$2:$E$1500="2012")), $J$2:$J$1500))

    confirmed with CTRL+SHIFT+ENTER

    [Note: normally I'd expect 2012 to be without quotes - using "2012" implies that column E is text-formatted....]
    Audere est facere

  3. #3
    Registered User
    Join Date
    03-31-2012
    Location
    KY
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: MAX with IF Returns Unexpected Value

    This worked. Thanks for your assistance.

    It didn't work until hitting Ctrl-Shift-Enter.

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1