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
Teradata Where Clause - Limit date to this month
Enhancing a hotspot button to include reply with history
Will there be a 13" Macbook with an iCore processor anytime soon? Safe to buy C2D?
CentOS 5.3: install: booting off USB: misunderstanding....is there a way I can INSTALL linux from an USB drive?
RSH client for windows 2008 r2
Crystal reports how to insert page break dynamically
SSIS getting data from SQL to Oracle
How do I get our WAN address using Windows Power Shell
Can you setup Remote Desktop Gateway and Remote Desktop Services on the same Server
PHP, ASP, Moneris