+ Reply to Thread
Results 1 to 11 of 11

query on if statement

  1. #1
    Forum Contributor
    Join Date
    07-08-2009
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003
    Posts
    142

    query on if statement

    Hi,

    I have a data.....

    If the mark is above 95%, then the grade should be 1
    If the mark is between 85 - 95%, then the grade should be 2
    If the mark is below 75%, then it should be grade 3
    If the mark ( value ) is blank or zero, then the grade should be blank...no value needed.

    can anyone help me with the if statement please ?

    Thanks
    Mani

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: query on if statement

    If the mark is above 95%, then the grade should be 1
    If the mark is between 85 - 95%, then the grade should be 2
    If the mark is below 75%, then it should be grade 3
    If the mark ( value ) is blank or zero, then the grade should be blank...no value needed.
    That doesn't seem to cover the option. What grade to you get between 75% - 85%?

    Maybe:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,496

    Re: query on if statement

    This should work, but what happens if the value is below 75% and above 0?
    =IF(OR(A1="",A1=0),"",LOOKUP(A1,{0.75,0.85,0.95},{3,2,1}))

    EDIT: I should read posts better instead of hurrying (unlike what Trevor did - took his time and read it) now that I reread it I see you want below 75 as 3, in that case with a gap like that mine won't work and I'd recommend TMS' solution.
    Last edited by Sam Capricci; 10-21-2015 at 06:48 AM.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  4. #4
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: query on if statement

    Good evening all,

    Based solely on the OPs request as stated, I have the following formula:-

    Please Login or Register  to view this content.
    Cheerio,
    vcoolio.

  5. #5
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,496

    Re: query on if statement

    so based on a reread of the OPs original request and some tweaking to my formula and not knowing what to do with the values between 75% and 85% I came up with these...
    =IF(OR(A1="",A1=0),"",LOOKUP(A1,{0.001,0.75,0.85,0.95},{3,"",2,1})) or to handle any errors =IFERROR(IF(OR(A1="",A1=0),"",LOOKUP(A1,{0.001,0.75,0.85,0.95},{3,"",2,1})),"")
    For what it's worth.

  6. #6
    Forum Contributor
    Join Date
    07-08-2009
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003
    Posts
    142

    Re: query on if statement

    Hi all,

    seems it is not working out well
    for all values, it returining value 1.

    95 & above should return grade 1
    85 - 94 should return the value 2
    75 - 84 should return the value 3
    1 - 74 should return the value 4
    anything that is blank or 0 in A1 should keep the value blank. no grade needed.

    I am sorry, if I was not clear earlier. thanks
    Mani

  7. #7
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,496

    Re: query on if statement

    then this should work for you... =IF(OR(A1="",A1=0),"",LOOKUP(A1,{0.009,0.75,0.85,0.95},{4,3,2,1}))

  8. #8
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: query on if statement

    Are values are in percentage or in numbers.

    If Percentage then =IFERROR(IF(OR(A6="",A6=0),"",LOOKUP(A6,{0.001,0.75,0.85,0.95},{4,3,2,1})),"")
    If Numbers then =IFERROR(IF(OR(A6="",A6=0),"",LOOKUP(A6,{1,75,85,95},{4,3,2,1})),"")
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  9. #9
    Forum Contributor
    Join Date
    07-08-2009
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003
    Posts
    142

    Re: query on if statement

    Hi TMS

    it is working fine. Thanks a ton..
    Mani

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: query on if statement

    You're welcome.

  11. #11
    Registered User
    Join Date
    10-07-2015
    Location
    Vancouver, BC, Canada
    MS-Off Ver
    Office 365
    Posts
    22

    Re: query on if statement

    Please find an example in the attached image.

    2015-10-21-Rank.png

+ 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. IF Statement Query
    By Phil_Lloyd_1979 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-30-2014, 07:09 AM
  2. Query Sum statement help
    By randell.graybill in forum Access Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2011, 03:42 AM
  3. If statement before web query
    By bmind in forum Excel General
    Replies: 1
    Last Post: 06-29-2009, 10:29 PM
  4. [SOLVED] Example of If then statement in query
    By jesika in forum Access Tables & Databases
    Replies: 2
    Last Post: 03-18-2009, 11:53 PM
  5. IF statement query.
    By Sasuke in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-05-2009, 08:02 AM
  6. IF Statement query
    By howardjo in forum Excel General
    Replies: 3
    Last Post: 11-28-2007, 10:48 AM
  7. Use MS Query in VBA to only get a SQL statement
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-23-2005, 02:06 PM

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