Calculating a percentage based on a field that has the sum of 0

  • Thread starter Kath via AccessMonster.com
  • Start date
K

Kath via AccessMonster.com

I am trying to do a calculation in a query that will determine a
percentage. The problem is in that some of the fields there may not be
responses, thus the sum of those fields would equate to 0 for that record.
Now if I do a sum of column1 \ sum of column2 to get my percentage, since
the sums are 0 it produces an error for those records that do not have any
input. Is there any way around this?

Here is my SQL if this helps any:
SELECT tblCA_5_6.CHART_ID, tblCA_5_6.PI_SITE_ID, tblCA_5_6.PI_E_ID, Count
(tblCA_5_6.PI_P_CLIENTID) AS CountOfPI_P_CLIENTID, Abs(Sum([PI_P_RECBE]))
AS [Sum of Rec CBE], Abs(Sum([PI_P_ABNORM])) AS [Sum ofAbnormal CBE], Abs
(Sum([PI_P_BEFEVAL])) AS [Sum Follow up Eval], [Sum of Rec CBE]/
[CountOfPI_P_CLIENTID] AS [Percentage of Recd CBE at comp], [Sum Follow up
Eval]/[Sum ofAbnormal CBE] AS [Percentage of clients with abnormal CBE for
further eval]
FROM tblCA_5_6
GROUP BY tblCA_5_6.CHART_ID, tblCA_5_6.PI_SITE_ID, tblCA_5_6.PI_E_ID;
 
D

David Seeto via AccessMonster.com

You can include a conditional statement in the formula, much as you can in
Excel:

iif([Sum ofAbnormal CBE] <> 0, [Sum Follow up Eval] / [Sum ofAbnormal CBE],
0)
 

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