|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
100% quandryThis 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 > I really want to make this work, but it seems fraught with issues!! You can't avoid rounding errors. One method might be to pick the> > Any ideas? 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 Mojo wrote:
.... Show quoteHide quote > This is why there's always fine print saying "Values may not total to> 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? exactly 100% due to rounding" -- Jim Shouldn't the total always be 100%. If so, then stop adding it up and
simply use a fixed value of 100% Mojo wrote: Show quoteHide quote > 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 Sorry Greg don't know what you mean.
"Greg Maxey" <gmaxey@mIKEvICTORpAPAsIERRA.oSCARrOMEOgOLF> wrote in message Shouldn't the total always be 100%. If so, then stop adding it up andnews:%239KK6Mf4JHA.5728@TK2MSFTNGP03.phx.gbl... simply use a fixed value of 100% Mojo wrote: Show quoteHide quote > 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
Show quote
Hide quote
On May 31, 9:29 am, "Mojo" <ple...@dont.spam.com> wrote: I mean if the sum of the value is always supposed to be 100% (rather> Sorry Greg don't know what you mean. > > "Greg Maxey" <gma...@mIKEvICTORpAPAsIERRA.oSCARrOMEOgOLF> wrote in message > > news:%239KK6Mf4JHA.5728@TK2MSFTNGP03.phx.gbl... > Shouldn't the total always be 100%. If so, then stop adding it up and > simply use a fixed value of 100% > > > > > > Mojo wrote: > > 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 > > -- > Greg Maxey - Word MVP > > My web sitehttp://gregmaxey.mvps.org > Word MVP web sitehttp://word.mvps.org- Hide quoted text - > > - Show quoted text - 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. Greg Maxey was telling us:
Greg Maxey nous racontait que : Show quoteHide quote > On May 31, 9:29 am, "Mojo" <ple...@dont.spam.com> wrote: Except that anal people like me will mentally ad up the numbers and notice >> Sorry Greg don't know what you mean. >> >> "Greg Maxey" <gma...@mIKEvICTORpAPAsIERRA.oSCARrOMEOgOLF> wrote in >> message >> >> news:%239KK6Mf4JHA.5728@TK2MSFTNGP03.phx.gbl... >> Shouldn't the total always be 100%. If so, then stop adding it up and >> simply use a fixed value of 100% >> >> >> >> >> >> Mojo wrote: >>> 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 >> >> -- >> 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. that the advertised 100% is wrong... I believe Larry has a workable solution... -- ______________________________ Jean-Guy Marcil Montreal, Canada Another possibility is not to display any total for the percentages -
let the other figures stand up for themselves. Peter Jamieson http://tips.pjmsn.me.uk Jean-Guy Marcil wrote: Show quoteHide quote > Greg Maxey was telling us: > Greg Maxey nous racontait que : > >> On May 31, 9:29 am, "Mojo" <ple...@dont.spam.com> wrote: >>> Sorry Greg don't know what you mean. >>> >>> "Greg Maxey" <gma...@mIKEvICTORpAPAsIERRA.oSCARrOMEOgOLF> wrote in >>> message >>> >>> news:%239KK6Mf4JHA.5728@TK2MSFTNGP03.phx.gbl... >>> Shouldn't the total always be 100%. If so, then stop adding it up and >>> simply use a fixed value of 100% >>> >>> >>> >>> >>> >>> Mojo wrote: >>>> 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 >>> -- >>> 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. > > 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... > 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. -- Show quoteHide quoteCheers macropod [Microsoft MVP - Word] "Mojo" <please@dont.spam.com> wrote in message news:Ou9RYce4JHA.4632@TK2MSFTNGP02.phx.gbl... > 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 > >
What files should I distribute (SAPI 5.3)?
How to test for array? DLL in Visual BASIC 6 Stone Wall GW-Basic Getting pixels from EMF (StdPicture) GetObject with VB6 ActiveX exe Mayayana and others: Know The Notes now for 98SE using MM's new 'Never Replace' scheme Format function question..... regfree-loading |
|||||||||||||||||||||||