Microsoft
Software
Hardware
Network
Question : Access 2003: Math question....Calculating a percentage
Hi EE,
I got help last year from EE in how to calcuate percentages.
A student can have one of the following grades in a course:
--------------------------
----------
----------
----------
----------
H - honors
HP - high pass
P - pass
Using a cross tab query, calculated (number of student) totals for each grade for a course
for ex:
course H HP P
==========================
===
MEDI 1107 26 41 102 <-- break down of how many students scored a particular grade
What the snippet below does is convert the total of students below to percentages.
26+41+102 = 169
26/169 * 100 = 15.38
41/169 * 100 = 24.26
102/169 * 100 = 60.35
Notice how the decimals portion is less than .50,
so the results of the calc are:
15%
24%
60%
that totals 99%
Is there any way to get the percentages to total 100% or is this to be expected in math?
tx for your thoughts and ideas, sandra
lngHCount = CLng(Nz(Me.txtHCount, 0))
lngHPCount = CLng(Nz(Me.txtHPcount, 0))
lngPCount = CLng(Nz(Me.txtPcount, 0))
lngTotal = lngHCount + lngHPCount + lngPCount
If lngTotal > 0 Then
lngHpct = (lngHCount / lngTotal) * 100
Else
lngHpct = 0
End If
If lngTotal > 0 Then
lngHPpct = (lngHPCount / lngTotal) * 100
Else
lngHPpct = 0
End If
If lngTotal > 0 Then
lngPpct = (lngPCount / lngTotal) * 100
Else
lngPpct = 0
End If
Me.txtHpct = lngHpct
Me.txtHPpct = lngHPpct
Me.txtPpct = lngPpct
Answer : Access 2003: Math question....Calculating a percentage
I think the only opportunity to get 100% is add this 1 to the value with maximal decimal part. In your example it will be 15.38. Change it to 16 and you will have minimal deviation from reality.
Random Solutions
show ip eigrp neighbors - What does the 'H' stand for ?
Load preview image using swfObject
cgi-bin/test.pl Not Working
Expand RAID 10
video driver - cannot find correct one - aspect 8640 laptop
VS2010, Slow C# Debugging
Free Store Locator PHP or Joomla Script
XP 10 inbound connection limit question
Windows 7 clients cannot connect to the server
VS2008 C# Printing