+ Reply to Thread
Results 1 to 14 of 14

error in nested if formula

  1. #1
    Registered User
    Join Date
    06-21-2008
    Posts
    10

    error in nested if formula

    Hi
    i wrote this formula but it gives me error
    =IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C","F")))

    why?
    what is the right?
    thanks in advance.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: error in nested if formula

    Looks OK. What kind of error you get?

  3. #3
    Registered User
    Join Date
    06-21-2008
    Posts
    10

    Re: error in nested if formula

    the error said
    the formula you typed contains an error

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: error in nested if formula

    You don't specify your geo location but perhaps try:

    =IF(B2>=90;"A";IF(B2>=80;"B";IF(B2>=70;"C";"F")))

    Or alternatively

    =LOOKUP(SUM(B2);{0\70\80\90},{"F"\"C\"B"\"A"})

  5. #5
    Registered User
    Join Date
    10-02-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: error in nested if formula

    The formula works fine provided cell B2 is number format. If it is formatted as text then it gives the wrong result. Are you sure that it is formatted as a number?

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: error in nested if formula

    Quote Originally Posted by DonkeyOte View Post
    You don't specify your geo location but perhaps try:

    =IF(B2>=90;"A";IF(B2>=80;"B";IF(B2>=70;"C";"F")))

    Or alternatively

    =LOOKUP(SUM(B2);{0\70\80\90},{"F"\"C\"B"\"A"})
    Missing a double quote around the C:

    =LOOKUP(SUM(B2);{0\70\80\90},{"F"\"C"\"B"\"A"})
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  7. #7
    Registered User
    Join Date
    06-21-2008
    Posts
    10

    Re: error in nested if formula

    =LOOKUP(SUM(B2);{0\70\80\90},{"F"\"C"\"B"\"A"})
    gives a message says
    the formula you typed contains an error

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: error in nested if formula

    seco, to repeat earlier point - in which country are located ?

    Presently we're guessing the problems are syntax related and that is in effect a waste of everyone's time...

  9. #9
    Registered User
    Join Date
    06-21-2008
    Posts
    10

    Re: error in nested if formula

    im located in saudi arabia

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: error in nested if formula

    OK, so either

    a) =IF(B2>=90;"A";IF(B2>=80;"B";IF(B2>=70;"C";"F")))
    (as advised previously)

    or

    b) =LOOKUP(SUM(B2);{0,70,80,90};{"F","C","B","A"})

    both should work based on your OP though the LOOKUP is perhaps a little more robust (& flexible).

  11. #11
    Registered User
    Join Date
    06-21-2008
    Posts
    10

    Re: error in nested if formula

    ok this one works well
    =LOOKUP(SUM(B2);{0,70,80,90};{"F","C","B","A"})

    now if i want to put a sum function instead of "F" and "C" characters ?
    like if from 0 to 70 put sum(A1:E1) instead of "F"
    how?
    thanks in advance.

  12. #12
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: error in nested if formula

    please outline what you want to do for each scenario

  13. #13
    Registered User
    Join Date
    06-21-2008
    Posts
    10

    Re: error in nested if formula

    ok
    from 0 to 70 sum(A1:A2)
    from 70 to 80 sum (A1:A3)
    from 80 to 90 sum (A1:A4)
    greater than 90 sum(A:A5)

  14. #14
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: error in nested if formula

    Your thresholds overlap so persuming you mean 0 to < 70, 70 to < 80 etc then

    =SUM(A1:INDEX(A2:A5;MATCH(SUM(B2);{0,70,80,90})))

    (assumes B2 always >=0 ... if not you can either a) alter 0 to -9.99999999999999E+307 or b) use MAX(0,B2) instead of SUM B2 (you may need to use ; rather than , ))

+ 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