Link to home
Start Free TrialLog in
Avatar of DataTransformationServices
DataTransformationServicesFlag for United States of America

asked on

Cannot get the percentages to equal 100

Hello - I've worked on this for a rediculous number of hours....I have a report that calculates the monthly percentages of incidents by incident type.  I calculate the percent and store it in a field that has a Number data type, field size of 'Double', a format of 'General Number' and a Decimal places = 2.   I do round the percent calculation and it looks like this:
Round(([rstTotalInc].Fields(2) * 100) / varTotalIncYear1, 3)
On the report, the percentage fields Format is set to Auto for Decimals.

The problem is that when I total the percentages, I cannot get them to equal 100 unless I allow the field on the report to go to 3 decimals.  Even then sometimes it sums to 99.999.  I've tried rounding, not rouding, changing the data type, etc.  I would like the percentages for each incident type to be percentages with no numbers to the right of the decimal and to have the same format for the total percentage and I would like it to equal 100.  Any help would be most appreciated.  Thank you.
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

yes, that is a problem.

say you have 3 rows with the values 1 , 1 and 1. total is 3. perc for all 3 rows is 33.33333333333 % ..
no matter how many digits you put, you won't be able to sum up to 100%.

this must be known to all those checking percentages, that the percentages are NOT to be summed, unless (at least 1) of the resulting percentages is "recalculated" to be the 100% - sum( of all the other percentages displayed ), however, then, that percentage value does not 100% match the actual calc, aka 33.34 vs 33.33 for example.

you CANNOT solve that issue.
Avatar of DataTransformationServices

ASKER

Thank you for your response.  I somewhat had a feeling that would be the case but it is being done in Excel.   In the Excel spreadsheet, the numbers are rounding and the total is 100 by summing the individual percents.  Any idea why it works there?
Don't use the Round function in the expression.

Use the format property of the text box to control how it's displayed. Round will change the value.

That way the control keeps the full "real" value and when you sum it up, you'll get the 100%.

Hope this helps.
Thanks so much, I did remove the rounding and use the Format command and it still comes out to 99.99999.  I guess I will have to give the user the ability to edit these values to equal 100.  Thanks again.
ASKER CERTIFIED SOLUTION
Avatar of Luke Chung
Luke Chung
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial