Solved

# Division by Zero error

Posted on 2013-09-26
Medium Priority
505 Views
Hi,

In Crystal i am trying trying to show the percentage of calls that were resolved within SLA grouped by the priority of the call, for example -

High 90%
Medium 98%
Low 99%

In my database if a call is within SLA then a field called 'withininfix' has a value of 0 or 1
1 = Within fix
0 = Not within fix.

I have the following formulas for each SLA -

#P1 - This formula counts the number of high calls

If (Command.priority} <> "High" then 1

#P1_fix - This counts the number of high priority calls within SLa

if {command.withinfix} = 1 and {Command.priority} = "High"
then 1 else 0

#P1% - This formula calculates the percentage of high calls within SLA

SUM ({@#P1_fix}) / SUM ({@#P1}) * 100 & "%"

When running the report I get a division by zero error, on the #P1% formula.

Can anyone help me?
0
Question by:dan_stan

LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 1000 total points
ID: 39523945
#P+ is indeed 0, you get that error.
you will have to put a IF @p1 is 0, you return a fixed value (like 0)
0

LVL 54

Assisted Solution

Rgonzo1971 earned 1000 total points
ID: 39523950
Hi,

Like this
``````If (SUM ({@#P1}) ) = 0 then 0 else (SUM ({@#P1_fix}) / SUM ({@#P1}) * 100 & "%")
``````
Regards
0

Author Comment

ID: 39524020
Thanks guys
0

LVL 35

Expert Comment

ID: 39524059
FWIW, you said that #P1 counts the number of high calls, but you have <> "High" in your post, so that formula is actually counting the calls that are _not_ "High".

Also, you might want to avoid using "#" at the beginning of a formula name.  CR puts a "#" at the beginning of running total names, so if you ever use running totals, it could get a bit confusing.

James
0

## Featured Post

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.