Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 577
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

I may be very sleepy, but try this and tell me why I get "OFF", instead of
"OK":

1. Open a new workbook
2. Enter the following:
Cell A1 =11813.21
B1 =5375.65
C1 =6437.56
D1 =IF(A1-B1-C1=0,"OK","OFF")

3. My result in D1 is "OFF" and it should be "OK"
4. Get a calculator or run it in your smart brain:
11813.21 minus 5375.65 minus 6437.56 = 0 (Big fat Zero!!)

If you play with the first three cells, sometimes it works, sometimes not.
I cannot see why or why not.

If the TRUE statement is performed in a seperate cell, and the IF is done in
another, I get "OK" when I should.

Is this a flaw in Excel 2003?


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

Try this:

=IF(A1-SUM(B1:C1)=0,"OK","OFF")



"Scott" wrote:

I may be very sleepy, but try this and tell me why I get "OFF", instead of
"OK":

1. Open a new workbook
2. Enter the following:
Cell A1 =11813.21
B1 =5375.65
C1 =6437.56
D1 =IF(A1-B1-C1=0,"OK","OFF")

3. My result in D1 is "OFF" and it should be "OK"
4. Get a calculator or run it in your smart brain:
11813.21 minus 5375.65 minus 6437.56 = 0 (Big fat Zero!!)

If you play with the first three cells, sometimes it works, sometimes not.
I cannot see why or why not.

If the TRUE statement is performed in a seperate cell, and the IF is done in
another, I get "OK" when I should.

Is this a flaw in Excel 2003?


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

Another way,

=IF(ROUND(A1-B1-C1,2)=0,"OK","OFF")



"Scott" wrote:

I may be very sleepy, but try this and tell me why I get "OFF", instead of
"OK":

1. Open a new workbook
2. Enter the following:
Cell A1 =11813.21
B1 =5375.65
C1 =6437.56
D1 =IF(A1-B1-C1=0,"OK","OFF")

3. My result in D1 is "OFF" and it should be "OK"
4. Get a calculator or run it in your smart brain:
11813.21 minus 5375.65 minus 6437.56 = 0 (Big fat Zero!!)

If you play with the first three cells, sometimes it works, sometimes not.
I cannot see why or why not.

If the TRUE statement is performed in a seperate cell, and the IF is done in
another, I get "OK" when I should.

Is this a flaw in Excel 2003?


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,081
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

The issue is rounding. One or more of the cells probably shows a value that
carries ou to many decimals past the 2 you have entered, but displays to,
say, 11813.21.

Use this formula instead

=IF(round(A1-B1-C1,2)=0,"OK","OFF")

"Scott" wrote:

I may be very sleepy, but try this and tell me why I get "OFF", instead of
"OK":

1. Open a new workbook
2. Enter the following:
Cell A1 =11813.21
B1 =5375.65
C1 =6437.56
D1 =IF(A1-B1-C1=0,"OK","OFF")

3. My result in D1 is "OFF" and it should be "OK"
4. Get a calculator or run it in your smart brain:
11813.21 minus 5375.65 minus 6437.56 = 0 (Big fat Zero!!)

If you play with the first three cells, sometimes it works, sometimes not.
I cannot see why or why not.

If the TRUE statement is performed in a seperate cell, and the IF is done in
another, I get "OK" when I should.

Is this a flaw in Excel 2003?


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 618
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

The problem arises because the numbers cannot be represented precisely in
binary. The only decimal numbers that can be represented precisely in
binary are 0.5, 0.25, 0.125, etc., and multiples thereof. That's why you
may need to round the result of the calculation.
--
David Biddulph

"Scott" wrote in message
...
I may be very sleepy, but try this and tell me why I get "OFF", instead of
"OK":

1. Open a new workbook
2. Enter the following:
Cell A1 =11813.21
B1 =5375.65
C1 =6437.56
D1 =IF(A1-B1-C1=0,"OK","OFF")

3. My result in D1 is "OFF" and it should be "OK"
4. Get a calculator or run it in your smart brain:
11813.21 minus 5375.65 minus 6437.56 = 0 (Big fat Zero!!)

If you play with the first three cells, sometimes it works, sometimes not.
I cannot see why or why not.

If the TRUE statement is performed in a seperate cell, and the IF is done
in
another, I get "OK" when I should.

Is this a flaw in Excel 2003?






  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 577
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

All the above formulas work, but what is wrong with mine? Try mine for
yourself; there are no extra fractions past two decimal places.

David's answer makes sense, but it is simple math that = zero. Why can't
Excel do that? It seems to be a flaw to me.

Thanks for the input.


"David Biddulph" wrote:

The problem arises because the numbers cannot be represented precisely in
binary. The only decimal numbers that can be represented precisely in
binary are 0.5, 0.25, 0.125, etc., and multiples thereof. That's why you
may need to round the result of the calculation.
--
David Biddulph

"Scott" wrote in message
...
I may be very sleepy, but try this and tell me why I get "OFF", instead of
"OK":

1. Open a new workbook
2. Enter the following:
Cell A1 =11813.21
B1 =5375.65
C1 =6437.56
D1 =IF(A1-B1-C1=0,"OK","OFF")

3. My result in D1 is "OFF" and it should be "OK"
4. Get a calculator or run it in your smart brain:
11813.21 minus 5375.65 minus 6437.56 = 0 (Big fat Zero!!)

If you play with the first three cells, sometimes it works, sometimes not.
I cannot see why or why not.

If the TRUE statement is performed in a seperate cell, and the IF is done
in
another, I get "OK" when I should.

Is this a flaw in Excel 2003?





  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 618
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

You'll find some more of the background at
http://www.cpearson.com/excel/rounding.htm
http://support.microsoft.com/kb/214118
http://support.microsoft.com/kb/78113

--
David Biddulph

"Scott" wrote in message
...
All the above formulas work, but what is wrong with mine? Try mine for
yourself; there are no extra fractions past two decimal places.

David's answer makes sense, but it is simple math that = zero. Why can't
Excel do that? It seems to be a flaw to me.

Thanks for the input.


"David Biddulph" wrote:

The problem arises because the numbers cannot be represented precisely in
binary. The only decimal numbers that can be represented precisely in
binary are 0.5, 0.25, 0.125, etc., and multiples thereof. That's why you
may need to round the result of the calculation.
--
David Biddulph

"Scott" wrote in message
...
I may be very sleepy, but try this and tell me why I get "OFF", instead
of
"OK":

1. Open a new workbook
2. Enter the following:
Cell A1 =11813.21
B1 =5375.65
C1 =6437.56
D1 =IF(A1-B1-C1=0,"OK","OFF")

3. My result in D1 is "OFF" and it should be "OK"
4. Get a calculator or run it in your smart brain:
11813.21 minus 5375.65 minus 6437.56 = 0 (Big fat Zero!!)

If you play with the first three cells, sometimes it works, sometimes
not.
I cannot see why or why not.

If the TRUE statement is performed in a seperate cell, and the IF is
done
in
another, I get "OK" when I should.

Is this a flaw in Excel 2003?







  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 837
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

"Scott" wrote:

All the above formulas work, but what is wrong with mine? Try mine for
yourself; there are no extra fractions past two decimal places.


=(A1-B1-C1)
evaluates to -9.09494701772928E-13, which is why your If function fails.

David's answer makes sense, but it is simple math that = zero. Why can't
Excel do that? It seems to be a flaw to me.


As David has pointed out, all of your decimal fractions are non-terminating
binary fractions that cannot be exactly represented in binary (just as 1/3
cannot be exactly represented as a decimal fraction). Excel (and almost all
other computer software) uses IEEE double precision binary representation of
floating point numbers. The decimal equivalents of the binary approximations
to your numbers are

11813.2099999999991268850862979888916015625
5375.649999999999636202119290828704833984375
6437.5600000000004001776687800884246826171875

Do the math yourself; Excel's answer is the correct result given the
unavoidable approximations to your initial numbers.

The reason that rounding solves the problem should be obvious. The
alternate proposal of =IF(A1-SUM(B1:C1)=0,"OK","OFF") is a less robust
solution that will not work for all numbers.

Jerry
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 577
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

Thanks guys. Fascinating. Us accountants cannot comprehend things that do
not balance.

"Jerry W. Lewis" wrote:

"Scott" wrote:

All the above formulas work, but what is wrong with mine? Try mine for
yourself; there are no extra fractions past two decimal places.


=(A1-B1-C1)
evaluates to -9.09494701772928E-13, which is why your If function fails.

David's answer makes sense, but it is simple math that = zero. Why can't
Excel do that? It seems to be a flaw to me.


As David has pointed out, all of your decimal fractions are non-terminating
binary fractions that cannot be exactly represented in binary (just as 1/3
cannot be exactly represented as a decimal fraction). Excel (and almost all
other computer software) uses IEEE double precision binary representation of
floating point numbers. The decimal equivalents of the binary approximations
to your numbers are

11813.2099999999991268850862979888916015625
5375.649999999999636202119290828704833984375
6437.5600000000004001776687800884246826171875

Do the math yourself; Excel's answer is the correct result given the
unavoidable approximations to your initial numbers.

The reason that rounding solves the problem should be obvious. The
alternate proposal of =IF(A1-SUM(B1:C1)=0,"OK","OFF") is a less robust
solution that will not work for all numbers.

Jerry

  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 947
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

Just for discussion, I like to have a custom function that adds Financial
data as a Currency data type.
In a program such as Microsoft's Access, one usually assigns monetary values
the Currency data type also.

For your example:
=A1-Total(B1:C1)=0
returns True.

A custom function is usually more sophisticated then this one, as it will
work on multiple areas, etc.

Function Total(rng As Range)
Dim T As Currency
Dim Cell As Range

T = 0
For Each Cell In rng.Cells
T = T + Cell
Next Cell
Total = T
End Function

Again, just an idea if you want to go this route.
--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"Scott" wrote in message
...
Thanks guys. Fascinating. Us accountants cannot comprehend things that
do
not balance.

"Jerry W. Lewis" wrote:

"Scott" wrote:

All the above formulas work, but what is wrong with mine? Try mine for
yourself; there are no extra fractions past two decimal places.


=(A1-B1-C1)
evaluates to -9.09494701772928E-13, which is why your If function fails.

David's answer makes sense, but it is simple math that = zero. Why
can't
Excel do that? It seems to be a flaw to me.


As David has pointed out, all of your decimal fractions are
non-terminating
binary fractions that cannot be exactly represented in binary (just as
1/3
cannot be exactly represented as a decimal fraction). Excel (and almost
all
other computer software) uses IEEE double precision binary representation
of
floating point numbers. The decimal equivalents of the binary
approximations
to your numbers are

11813.2099999999991268850862979888916015625
5375.649999999999636202119290828704833984375
6437.5600000000004001776687800884246826171875

Do the math yourself; Excel's answer is the correct result given the
unavoidable approximations to your initial numbers.

The reason that rounding solves the problem should be obvious. The
alternate proposal of =IF(A1-SUM(B1:C1)=0,"OK","OFF") is a less robust
solution that will not work for all numbers.

Jerry



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
Copy and paste between windows in excel 2003 will not work april g. Excel Worksheet Functions 0 March 2nd 06 07:35 PM
My fill color and font color do not work in Excel Std Edition 2003 chapstick Excel Discussion (Misc queries) 1 September 11th 05 08:48 PM
Excel 97 - Adding Every 8th Row - Formula should work, but doesn't Damaeus Excel Worksheet Functions 12 January 23rd 05 04:52 PM
Excel 2003 - Formula result shows as 0:00 Serena Excel Worksheet Functions 4 November 11th 04 10:18 PM


All times are GMT +1. The time now is 10:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"