100% quandry

M

Mojo

Hi All

This might be an age old problem, but I just wanted to see if I wasn't
missing something obvious in my code.

Basically I have say 31 people (this figure can range from 10 to 100) who
are put into 8 categories. Once they have been categorised I simply need to
show how many are in each category as a number and as a percentage. Now the
number aspect of display is easy, but I'm coming unstuck with the percetange
aspect.

In essence as I do my % calc for each category sometimes certain values are
1% less or more than they should be and as you add up the displayed figures
the total might come out at 99% or 101%, which looks daft.

An example of a display problem is as follows

1 0 2 9 11 5 0 2 = 30 people
3% 0% 7% 30% 37% 17% 0% 7% = 101% !!!!

My code for each percentage value is simply:

Round((intPeopleCount / intTotalPeopleCount) * 100, 0) & "%"

I really want to make this work, but it seems fraught with issues!!

Any ideas?

Thanks
 
L

Larry Serflaten

I really want to make this work, but it seems fraught with issues!!
Any ideas?

You can't avoid rounding errors. One method might be to pick the
highest single value (11 in your case) and give it the percentage you
need to reach 100%. In other words, total up all the other percentages
and give the remainder (from 100%) to that one group.

LFS
 
J

Jim Mack

Mojo wrote:

....
An example of a display problem is as follows

1 0 2 9 11 5 0 2 = 30 people
3% 0% 7% 30% 37% 17% 0% 7% = 101% !!!!

My code for each percentage value is simply:

Round((intPeopleCount / intTotalPeopleCount) * 100, 0) & "%"

I really want to make this work, but it seems fraught with issues!!

Any ideas?


This is why there's always fine print saying "Values may not total to
exactly 100% due to rounding"
 
G

Greg Maxey

Shouldn't the total always be 100%. If so, then stop adding it up and
simply use a fixed value of 100%
 
M

Mojo

Sorry Greg don't know what you mean.


Shouldn't the total always be 100%. If so, then stop adding it up and
simply use a fixed value of 100%
 
G

Greg Maxey

Sorry Greg don't know what you mean.


Shouldn't the total always be 100%.  If so, then stop adding it up and
simply use a fixed value of 100%
















--
Greg Maxey -  Word MVP

My web sitehttp://gregmaxey.mvps.org
Word MVP web sitehttp://word.mvps.org- Hide quoted text -

- Show quoted text -

I mean if the sum of the value is always supposed to be 100% (rather
to some figure close to 100% that your equation produces) then stop
using the equation and just type in 100% in the place of the equation.
 
J

Jean-Guy Marcil

Greg Maxey was telling us:
Greg Maxey nous racontait que :
I mean if the sum of the value is always supposed to be 100% (rather
to some figure close to 100% that your equation produces) then stop
using the equation and just type in 100% in the place of the equation.

Except that anal people like me will mentally ad up the numbers and notice
that the advertised 100% is wrong...

I believe Larry has a workable solution...
 
M

macropod

Answered in microsoft.public.excel.misc

Please don't post the same question in multiple forums without linking all of them. Your post in microsoft.public.excel.misc shows
that you know how to do this.

Plus, if your query is specific to one application, it's best limiting the post to a forum dealing with that application - the range
of newsgroups you've posted to suggest you haven't given much though to this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top