+ Reply to Thread
Results 1 to 4 of 4

Nested IF question

  1. #1
    Registered User
    Join Date
    12-13-2011
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Nested IF question

    Sorry, lots of searching but can't find the solution. I get nested If functions, I'm trying to come up with this.

    A1
    If cell A2 is <6, assign 0.
    If cell A2 is 6-19, assign 0.5.
    If cell A2 is 20-40, assign 0.75.
    If cell A2 is >40, assign 1.25.

    I've come up with this:
    =IF(A2<6,0,IF(A2>5,0.5,IF(A2>19,0.75,IF(A2>40,1.25))))

    And it works, however it won't go above the second nested IF formula. If I put say '20', in to A2, it still returns 0.5.

    Kind of scratching my head.

    Thanks.

  2. #2
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Nested IF question

    How about a different approach:

    Please Login or Register  to view this content.
    Cheers,
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Nested IF question

    ...just to explain why your version doesn't work....

    The IFs are evaluated in order so with this

    =IF(A2<6,0,IF(A2>5,0.5,IF(A2>19,0.75,IF(A2>40,1.25))))

    the first IF assigns zero if A2 < 6, the second IF assigns 0.5 if A2 > 5.......that's it. If A2 doesn't fall in to that first category it will fall into the second - the final two IFs are never evaluated (anything > 19 or > 40 has already been gobbled up by the > 5 category). To make it work the way you want you need to go from low to high or high to low, e.g.

    =IF(A2>40,1.25,IF(A2>19,0.75,IF(A2>5,0.5,0)))

    Note: I didn't need the final IF because the first 3 cover all numbers > 5....so everything else falls into <=5, I don't need to check for that.....
    Last edited by daddylonglegs; 12-13-2011 at 08:50 PM.
    Audere est facere

  4. #4
    Registered User
    Join Date
    12-13-2011
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Nested IF question

    Thanks much folks. I used the first reply but thanks for the explanation.

+ 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