SOLVED

Sum function not working properly

%3CLINGO-SUB%20id%3D%22lingo-sub-1418843%22%20slang%3D%22en-US%22%3ESum%20function%20not%20working%20properly%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1418843%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20an%20issue%20with%20the%20SUM%20function%20in%20excel%20where%20I%20have%20it%20sum%20numbers%20with%20only%202%20decimals%20but%20the%20result%20is%20a%20longer%20decimal%20(example%3A%202.00000001).%3C%2FP%3E%3CP%3EHere%20is%20my%20specific%20example%3C%2FP%3E%3CP%3EI%20have%20a%20basic%20income%20statement%20spreadsheet%20that%20I%20use%20to%20track%20the%20income%20and%20expenses%20of%20a%20rental%20I%20have.%20For%20each%20month%2C%20I%20have%20function%201%20(monthly%20income)%20that%20adds%20all%20the%20income%20values%20and%20function%202%20(monthly%20expenses)%20to%20add%20all%20the%20expense%20values.%20Then%20I%20have%20function%203%20(monthly%20net%20income)%20that%20takes%20function%201%20and%20subtracts%20function%202.%20I%20then%20have%20function%204%20(annual%20net%20income)%20to%20sum%20up%20all%20the%20function%203.%26nbsp%3B%3C%2FP%3E%3CP%3EAll%20my%20values%20are%20currency%20so%20none%20of%20them%20go%20past%202%20decimal%20points%20so%20adding%20them%20all%20together%20should%20only%20result%20in%20a%202%20decimal%20value%3B%20However%2C%20my%20total%20net%20income%20for%20the%20year%20comes%20out%20to%20some%20long%20decimal%20(ex.%20%24500.0000001).%20This%20has%20happen%20to%20me%20a%20few%20times%20now%20with%20other%20spreadsheets%20that%20contain%20lots%20of%20SUM%20function%20that%20build%20on%20each%20other.%3C%2FP%3E%3CP%3EI%20know%20I%20can%20use%20the%20ROUND%20function%20to%20eliminate%20this%20but%20the%20problem%20isn't%20a%20rounding%20issue%20(%2450.25%20%2B%20%2449.75%20should%20equal%20%24100.00%20not%20%24100.000000001).%20Plus%20I%20don't%20want%20have%20to%20add%20the%20ROUND%20function%20every%20time%20I%20use%20the%20SUM%20function%20just%20in%20case%20this%20error%20occurs.%20My%20guess%20is%20that%20there%20is%20some%20kind%20of%20bug%20that%20happens%20when%20referencing%20so%20many%20functions%20to%20other%20functions.%20Anyone%20else%20have%20this%20issue%2C%20know%20what%20is%20causing%20it%20and%2For%20how%20to%20fix%20it%3F%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1418843%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1419080%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20function%20not%20working%20properly%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1419080%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F680256%22%20target%3D%22_blank%22%3E%40JLV_96%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20are%20the%20sources%20for%20all%20your%20figures%3F%20Do%20some%20come%20from%20outside%20sources%3F%20Do%20some%20come%20from%20other%20mathematical%20operations%2C%20notably%20multiplication%20or%20division%2C%20where%20they%20might%20appear%20as%20two%20decimals%20but%20in%20fact%20carry%20a%20%3CEM%3Ede%20minimus%3C%2FEM%3E%20fraction%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20you%20not%20just%20display%20two%20decimals%20(no%20need%20to%20round)%3F%20I%20mean%2C%20if%20it%20really%20is%20at%20the%20level%20of%20something%20like%20one-millionth%2C%20it's%20not%20going%20to%20become%20a%20problem%20anyway%2C%20is%20it%3F%20%5BI%20say%20that%2C%20fully%20realizing%20that%20if%20I%20were%20in%20your%20place%2C%20I'd%20want%20to%20get%20to%20the%20bottom%20of%20it%20too.%5D%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1419269%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20function%20not%20working%20properly%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1419269%22%20slang%3D%22en-US%22%3E%3CP%3EIt%20is%20a%20rounding%20problem.%20The%20computer%20converts%20your%20numbers%20to%20binary%2C%20performs%20the%20calculations%2C%20then%20converts%20it%20back%20to%20base%2010.%20There%20are%20some%20base%2010%20decimals%20that%20cannot%20be%20represented%20exactly%20as%20binary%20fractions.%20So%2C%20you%20can%20get%20small%20rounding%20errors.%3CBR%20%2F%3E%3CBR%20%2F%3EAny%20time%20you%20are%20working%20with%20decimals%2C%20you%20should%20round%20your%20calculations%20even%20if%20all%20of%20the%20inputs%20are%20only%20to%20a%20certain%20decimal%20place%20(especially%20if%20you%20are%20using%20something%20like%20IF(calcresult%3Dx...).%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22http%3A%2F%2Fwww.cpearson.com%2FExcel%2Frounding.htm%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.cpearson.com%2FExcel%2Frounding.htm%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEdit%3A%20but%20I'm%20assuming%20you've%20already%20checked%20the%20inputs%20and%20any%20precedent%20calculations%20as%20already%20suggested%20and%20confirmed%20that's%20not%20the%20problem.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1420167%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20function%20not%20working%20properly%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1420167%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675152%22%20target%3D%22_blank%22%3E%40JMB17%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%3C%2FP%3E%3CP%3EI%20have%20the%20same%20problem%20using%20a%20simple%20function%20like%20this%3A%3C%2FP%3E%3CP%3E%3DIF(SUM(B16%3AG16)%3DSUM(H12%3AH15)%3B%22ok%22%3B%22error%3A%20%22%20%26amp%3B%20SUM(B16%3AG16)-SUM(H12%3AH15))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Esum%20are%20identical%20but%20excel%20display%20something%20like%20that%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CTABLE%20width%3D%22180%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22180%22%3Eerror%3A%20-8%2C5265128291212E-14%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ein%20the%20SUM%20page%20of%20the%20online%20manual%20they%20don't%20say%20NOT%20to%20use%20in%20such%20a%20case%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1420528%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20function%20not%20working%20properly%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1420528%22%20slang%3D%22en-US%22%3EYou%20can%20use%20it%20that%20way%2C%20but%20you%20have%20to%20round%20the%20results%20to%20the%20desired%20number%20of%20decimals%20if%20B16%3AG16%20and%2For%20H12%3AH15%20contains%20decimal%20data.%20If%20the%20data%20is%20integers%2C%20then%20you%20don't%20need%20to%20round%20as%20all%20integers%20can%20be%20expressed%20exactly%20in%20binary.%3CBR%20%2F%3E%3CBR%20%2F%3E%3DIF(ROUND(SUM(B16%3AG16)%2C2)%3DROUND(SUM(H12%3AH15)%2C2)%3B%22ok%22%3B%22error%3A%20%22%20%26amp%3B%20ROUND(SUM(B16%3AG16)%2C2)-ROUND(SUM(H12%3AH15)%2C2))%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1421349%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20function%20not%20working%20properly%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1421349%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F680922%22%20target%3D%22_blank%22%3E%40ClaudioScacchi%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20more%20option%20which%20could%20help%20is%20this%20setting%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20526px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F194808i074C52E2F955A288%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMSFT%20collected%20all%20in%20one%20place%20here%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Ftroubleshoot%2Fexcel%2Ffloating-point-arithmetic-inaccurate-result%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EFloating-point%20arithmetic%20may%20give%20inaccurate%20results%20in%20Excel%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1421404%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20function%20not%20working%20properly%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1421404%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675152%22%20target%3D%22_blank%22%3E%40JMB17%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20comparing%20values%20in%20Euro%20...%20a%20common%20task%2C%20I%20think%3C%2FP%3E%3CP%3Eso%20everytime%20I%20must%20remember%20to%20round%20if%20I%20want%20use%20the%20result%20in%20a%20IF%20function%20...%3C%2FP%3E%3CP%3Eusing%20excel%20from%20the%202.1%20version%20and%20I%20never%20had%20to%20use%20a%20IF(SUM(...)%20with%20currency%20...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Etnks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1421430%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20function%20not%20working%20properly%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1421430%22%20slang%3D%22en-US%22%3Eok%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1421580%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20function%20not%20working%20properly%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1421580%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20will%20work%20if%20the%20formula%20was%20referencing%20a%20cell%20containing%20the%20sum%2C%20but%20not%20when%20the%20sum%20is%20part%20of%20the%20formula%20itself.%3C%2FP%3E%3CP%3E%3DIF(SUM(x)%20%3D%20SUM(y)%2C%20true%2C%20false)%20will%20still%20fail.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20that%20option%20selected%3A%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Visitor

I have an issue with the SUM function in excel where I have it sum numbers with only 2 decimals but the result is a longer decimal (example: 2.00000001).

Here is my specific example

I have a basic income statement spreadsheet that I use to track the income and expenses of a rental I have. For each month, I have function 1 (monthly income) that adds all the income values and function 2 (monthly expenses) to add all the expense values. Then I have function 3 (monthly net income) that takes function 1 and subtracts function 2. I then have function 4 (annual net income) to sum up all the function 3. 

All my values are currency so none of them go past 2 decimal points so adding them all together should only result in a 2 decimal value; However, my total net income for the year comes out to some long decimal (ex. $500.0000001). This has happen to me a few times now with other spreadsheets that contain lots of SUM function that build on each other.

I know I can use the ROUND function to eliminate this but the problem isn't a rounding issue ($50.25 + $49.75 should equal $100.00 not $100.000000001). Plus I don't want have to add the ROUND function every time I use the SUM function just in case this error occurs. My guess is that there is some kind of bug that happens when referencing so many functions to other functions. Anyone else have this issue, know what is causing it and/or how to fix it??

8 Replies
Highlighted

@JLV_96 

 

What are the sources for all your figures? Do some come from outside sources? Do some come from other mathematical operations, notably multiplication or division, where they might appear as two decimals but in fact carry a de minimus fraction?

 

Can you not just display two decimals (no need to round)? I mean, if it really is at the level of something like one-millionth, it's not going to become a problem anyway, is it? [I say that, fully realizing that if I were in your place, I'd want to get to the bottom of it too.]

Highlighted
Best Response confirmed by JLV_96 (Occasional Visitor)
Solution

It is a rounding problem. The computer converts your numbers to binary, performs the calculations, then converts it back to base 10. There are some base 10 decimals that cannot be represented exactly as binary fractions. So, you can get small rounding errors.

Any time you are working with decimals, you should round your calculations even if all of the inputs are only to a certain decimal place (especially if you are using something like IF(calcresult=x...).

http://www.cpearson.com/Excel/rounding.htm

 

Edit: but I'm assuming you've already checked the inputs and any precedent calculations as already suggested and confirmed that's not the problem.

Highlighted

@JMB17 

 

Hi

I have the same problem using a simple function like this:

=IF(SUM(B16:G16)=SUM(H12:H15);"ok";"error: " & SUM(B16:G16)-SUM(H12:H15))

 

sum are identical but excel display something like that

 

error: -8,5265128291212E-14

 

in the SUM page of the online manual they don't say NOT to use in such a case

 

 

 

Highlighted
You can use it that way, but you have to round the results to the desired number of decimals if B16:G16 and/or H12:H15 contains decimal data. If the data is integers, then you don't need to round as all integers can be expressed exactly in binary.

=IF(ROUND(SUM(B16:G16),2)=ROUND(SUM(H12:H15),2);"ok";"error: " & ROUND(SUM(B16:G16),2)-ROUND(SUM(H12:H15),2))
Highlighted

@ClaudioScacchi 

One more option which could help is this setting

image.png

 

MSFT collected all in one place here Floating-point arithmetic may give inaccurate results in Excel 

Highlighted

@JMB17 

I'm comparing values in Euro ... a common task, I think

so everytime I must remember to round if I want use the result in a IF function ...

using excel from the 2.1 version and I never had to use a IF(SUM(...) with currency ...

 

 

tnks

 

Highlighted
ok
Highlighted

@Sergei Baklan 

 

That will work if the formula was referencing a cell containing the sum, but not when the sum is part of the formula itself.

=IF(SUM(x) = SUM(y), true, false) will still fail.

 

With that option selected: