+ Reply to Thread
Results 1 to 10 of 10

Nested If functions and VLOOKup - PLease help

  1. #1
    Registered User
    Join Date
    04-08-2017
    Location
    canada
    MS-Off Ver
    2016
    Posts
    10

    Nested If functions and VLOOKup - PLease help

    Hey there guys so I had a few inquiries in which I would appreciate some clarification. So if we have a question that says =IF(score<80,"b",If(score<70,"c",If(score<60,"d",If(score<50,"f","a")))), what is the grade you would receive for a mark of 45, logically it would be assumed that it would receive an F, but the correct answer is B. Anyone know why that is?

    There is also another question with LOOKUP function, I have posted this in the attachment. Therefore, my question is why is that 5 is N/A and it is also not an f as it is less then 10, however Understand why it is N\A but wanted more clarification in regards to why some question turns out like these, and what are the rules of reading such statement and how you would understand the boundaries because some can not be read logically.

    Thank you in advnce.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested If functions and VLOOKup - PLease help

    There is no attachment, so I can't answer your second question.

    Regarding the first question, though, your first IF is checking to see if score is less than 80 and return a "b" if it is. If the score is actually 45 then this IS less than 80, so a b will be returned - Excel will never check the other conditions.

    To get the correct answer, you should reverse the order in which you do the comparisons, like this:

    =IF(score<50,"f",If(score<60,"d",If(score<70,"c",If(score<80,"b","a"))))

    Hope this helps.

    Pete

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested If functions and VLOOKup - PLease help

    If you want to attach a sample Excel workbook, here is the procedure.

    Click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

    Please note that the Paperclip icon does not work on this Forum.

    Hope this helps.

    Pete

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Nested If functions and VLOOKup - PLease help

    Agree with Pete, if you are testing for less than, you need to start from small to big, if testing for greater than, start from big to small.

    However, another option here would be a small lookup table and use vlookup()
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: Nested If functions and VLOOKup - PLease help

    You could use this:

    =LOOKUP(score,{0,50,60,70,80},{"F","D","C","B","A"})
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    04-08-2017
    Location
    canada
    MS-Off Ver
    2016
    Posts
    10

    Re: Nested If functions and VLOOKup - PLease help

    Hey pete,

    thank you, However if this is the case then why doesn't the same apply to the other condition, lets say if it asks what is a score of 60, it would naturally be a "C" but following that mentality it mean that it is also B?

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested If functions and VLOOKup - PLease help

    No. The formula that I gave you checks first of all if the value of score is less than 50 - if it is then the formula would return "f" and would not bother to check any of the other conditions, i.e. it exits at that point. If it is not less than 50 then the next criterion is examined, i.e. is score less than 60? If it is then "d" will be returned (with no further checking), and if it isn't then the next criterion will be applied, i.e. is it less than 70? If yes, then return "c" (and stop), otherwise check the next criterion - is it less than 80? If it is then return "b" otherwise return "a".

    You can see that to get a "c" returned, for example, the score has to be 60 or over AND less than 70.

    Hope this helps.

    Pete

  8. #8
    Registered User
    Join Date
    04-08-2017
    Location
    canada
    MS-Off Ver
    2016
    Posts
    10

    Re: Nested If functions and VLOOKup - PLease help

    here is my second question in regards to the .lookup function
    Attached Images Attached Images

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested If functions and VLOOKup - PLease help

    Compare this with the formula that Ali gave you in Post #5 - can you see why her formula would not produce #N/A for a score of 5?

    Pete

  10. #10
    Registered User
    Join Date
    04-08-2017
    Location
    canada
    MS-Off Ver
    2016
    Posts
    10

    Re: Nested If functions and VLOOKup - PLease help

    Hey pete, so for the If question, if it were to ask what is a score of 65, that means it will also receive a B is that correct?b because it will look towards the first statement to see if it satisfies the condition, in which 65 is lower then 80, therefore it would be given a B, Instead of a C. Furthermore, for the second question Why is that 5 would receive a N/A and not a F, I just want some clarification in regards in how to read the statements more readily as sometime it can be against common logic. such that if 5 is N/A and anything between 10-14 is F, and 15-19 is C and so forth, then 30 is an A, even though 30 has not been identified, so what is a mark of 40? is that also A (even though logically I get it, it would be an A). I just want to better understand how the boundaries are read by the computer or how the functions are read. However, I Fully understand the IF function. Also another question is why someone would choose V-loockup instead of Loockup, as I know V-look up is or vertical, and also what about when people choose Match and Index. Sorry for the long message.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Nested vlookup or nested IFAND function?
    By jeptik in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-11-2017, 02:27 AM
  2. Replies: 6
    Last Post: 03-17-2015, 01:35 AM
  3. Vlookup / nested functions
    By sdoremus123 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-24-2013, 12:10 AM
  4. [SOLVED] Nested Functions, If, VLOOKUP
    By AusVivienne in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-17-2012, 09:47 PM
  5. Vlookup with nested if functions
    By shakes347 in forum Excel General
    Replies: 4
    Last Post: 07-13-2010, 10:05 AM
  6. Using VLOOKUP instead of Nested IF Functions
    By cbee907 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-03-2010, 05:26 PM
  7. [SOLVED] nested if(and) functions
    By Rohan in forum Excel General
    Replies: 3
    Last Post: 08-11-2005, 09:05 PM

Tags for this Thread

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