Omega Owners Forum

Chat Area => General Discussion Area => Topic started by: Nickbat on 04 September 2007, 21:05:49

Title: Any Excel experts out there?
Post by: Nickbat on 04 September 2007, 21:05:49
I can't get my head around this. It all arose as a result of a very simple pie chart I was doing for a client.

Take the following six numbers:
41.00
22.68
11.03
8.56
8.63
7.23

Format the cells as numbers to two decimal places, then total them. It comes out to 99.13

Then reformat the cells to one decimal place:

41.0
22.7
11.0
8.6
8.6
7.2

Excel does the rounding up/down correctly and the total comes to 99.1.

Then reformat the cells to no decimal places:

41
23
11
9
9
7

Excel again rounds up and down correctly and makes the total 99.

HOWEVER, if you add this last set of numbers up (in your head, or on a calculator if you were born after 1970  ;D), the total is 100.

How can that be?
Title: Re: Any Excel experts out there?
Post by: STMO123 on 04 September 2007, 21:16:12
I'm no expert at excel Nick, but, simple maths tells me you've added 0.3 to the 22.7 and 0.4 to both the 8.6's which equals........1 :D
Title: Re: Any Excel experts out there?
Post by: Grumpy on 04 September 2007, 21:16:27
Because a spreadsheet will always sum the numbers correctly, not just
to the decimal point that you wish it to display.

When it displays the figures, it will round it up or down and
display it to the decimal point that you specified.

In your last column, it has rounded up the figures to display as
whole numbers.
Title: Re: Any Excel experts out there?
Post by: Entwood on 04 September 2007, 21:17:15
If you don't format the total line you will see why !!!  although you change the format of each cell you only change it's display .. NOT the content which remains as you  input it .. so the total is rounded on the CONTENT not the display .. it is therefore rounded down to 99  even though each cell is rounded differently.. some up some down
Title: Re: Any Excel experts out there?
Post by: Golfbuddy on 04 September 2007, 21:26:46
Just because you change the formatting to 'nil' decimal places doesn't mean that the numbers have changed. In your example, the two 9's are still actually 8.56 and 8.63, which makes 17.19 which when rounded to 'nil' decimal places makes 17 and not 18 which it would in your example and the total still makes 99.13. So the answer is quite simple, when you add the column of numbers it does add up to 99 rounded to two decimal places; it will never total 100.

 :P :P
Title: Re: Any Excel experts out there?
Post by: Nickbat on 04 September 2007, 21:36:35
Thanks guys.

So, it is possible to provide spreadsheet data which nominally shows an incorrect total. I suppose, if you were smart, you could exploit this feature. But, I'm not smart, so I'll stop thinking about it.  ::) ;D ;D
Title: Re: Any Excel experts out there?
Post by: STMO123 on 04 September 2007, 21:50:52
It's possible to manipulate any list of figures Nick, just depends whether you choose to round them up...or down ;)
Title: Re: Any Excel experts out there?
Post by: Entwood on 04 September 2007, 21:51:15
It has been exploited .... several times  !!

The classic case was quite a few years back in the early days of computing/accountancy, a worker in an american bank realised that interest payments were calculated to 4 decimal places of dollars  ie .. 2 decimal places of cents eg $01.1124 but only paid to accounts as cents and always the bank "rounded down"   so $01.1124 would be paid as $01.11. He wrote a small program to have the other little bits $0.0024 (1/4 of a cent) to be paid into a secret account he controlled. Doesn't sound much but with a few hundred thousand accounts it soon added up to a nice amount.

Urban myth on this is that he was never prosecuted but employed by the bank to look for others trying to do similar  !!  :)
Title: Re: Any Excel experts out there?
Post by: Golfbuddy on 04 September 2007, 22:01:06
Quote
Thanks guys.

So, it is possible to provide spreadsheet data which nominally shows an incorrect total. I suppose, if you were smart, you could exploit this feature. But, I'm not smart, so I'll stop thinking about it.  ::) ;D ;D

Good idea. Go back to designing hall cupboards.  :y
Title: Re: Any Excel experts out there?
Post by: Nickbat on 04 September 2007, 22:04:30
Quote
Quote
Thanks guys.

So, it is possible to provide spreadsheet data which nominally shows an incorrect total. I suppose, if you were smart, you could exploit this feature. But, I'm not smart, so I'll stop thinking about it.  ::) ;D ;D

Good idea. Go back to designing hall cupboards.  :y

Cheeky git!  >:( >:( ;) ;D ;D ;D ;D

Actually SWMBO was very happy with the cupboard, but demanded I paint the door white as the mahogany clashed with the new pine.  :(
Title: Re: Any Excel experts out there?
Post by: Golfbuddy on 04 September 2007, 22:08:58
Quote
Quote
Quote
Thanks guys.

So, it is possible to provide spreadsheet data which nominally shows an incorrect total. I suppose, if you were smart, you could exploit this feature. But, I'm not smart, so I'll stop thinking about it.  ::) ;D ;D

Good idea. Go back to designing hall cupboards.  :y

Cheeky git!  >:( >:( ;) ;D ;D ;D ;D

Actually SWMBO was very happy with the cupboard, but demanded I paint the door white as the mahogany clashed with the new pine.  :(

Would have looked nice in a subtle shade of salmon.  ::)
Title: Re: Any Excel experts out there?
Post by: Nickbat on 04 September 2007, 22:13:16
Quote
Quote
Quote
Quote
Thanks guys.

So, it is possible to provide spreadsheet data which nominally shows an incorrect total. I suppose, if you were smart, you could exploit this feature. But, I'm not smart, so I'll stop thinking about it.  ::) ;D ;D

Good idea. Go back to designing hall cupboards.  :y

Cheeky git!  >:( >:( ;) ;D ;D ;D ;D

Actually SWMBO was very happy with the cupboard, but demanded I paint the door white as the mahogany clashed with the new pine.  :(

Would have looked nice in a subtle shade of salmon.  ::)


I think your angling for a bunch of fives.   ;D ;D ;)