+ Reply to Thread
Results 1 to 5 of 5

Error in IF statement with greater than or equal to

  1. #1
    Registered User
    Join Date
    11-20-2015
    Location
    USA
    MS-Off Ver
    2007
    Posts
    2

    Error in IF statement with greater than or equal to

    Getting an error in a simple formula (using Excel 2007)

    Formula: =IF(B1<=0.05,"within limits","out of limits")

    Where B1 is a simple calculated value (subtraction between two numbers)

    Getting the same value but using different starting numbers is producing different results from the formula. I have attached a file in which i just looked at 100 examples (0-100) and have errors between 8-31.

    Any thoughts as to why I would get different results even thought the calculated value never changes? Something with rounding in the background?

    Driving me nuts!

    Thanks for the help!
    Attached Files Attached Files
    Last edited by PeopleHelpingPeople; 11-20-2015 at 01:41 PM. Reason: Issue Solved - Thanks!

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Error in IF statement with greater than or equal to

    I don't see any errors on your spreadsheet. As an alternative try this formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Error in IF statement with greater than or equal to

    The issue stems from the fact that the computer is performing calculations in binary and we use decimal system. Sometimes there is not an exact match between them. If you select column B and format cells> number with 15 decimals, you will see the issue.

    You can modify your formula either in B
    =ROUND(C2-D2,2)
    or in A
    =IF(ROUND(B2,4)<= 0.05......)
    Does that help?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Error in IF statement with greater than or equal to

    Hi,

    You've hit the well known 'arithmetical precision' factor.
    If you choose to show say B7 to 16 decimal places you'll see the number is actually 0.0500000000000007
    B6 similarly is 0.4999999999999800

    Change your formula to

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

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    11-20-2015
    Location
    USA
    MS-Off Ver
    2007
    Posts
    2

    Re: Error in IF statement with greater than or equal to

    Thanks so much, adding in the round function fixed the error.

    thanks for the quick reply's!

+ 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] IF date is greater than or equal to X but less than or equal to y
    By LloydGilmore in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-09-2019, 05:35 AM
  2. greater than, equal to. less than
    By Robbosan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-10-2015, 12:49 PM
  3. If statement for total is greather of equal 2 and 2 cells greater than zero
    By Faridwahidi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-02-2014, 01:25 AM
  4. SumIfs containing a greater than or equal to And less than or equal to
    By teton88 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 04-15-2014, 07:47 PM
  5. [SOLVED] COUNTIFS function w/greater than or equal to, and less than or equal to time values
    By AliciaRenee in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-27-2014, 03:57 PM
  6. [SOLVED] Greater than less than a equal to
    By Crackle1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-16-2014, 01:52 AM
  7. Greater than or equal
    By SuncrestInsurance in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-18-2011, 07:52 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