Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Divide by zero error Post Reply Post New Topic
Author Message
bhar4
Newbie
Newbie


Joined: 18 Jul 2012
Online Status: Offline
Posts: 11
Quote bhar4 Replybullet Topic: Divide by zero error
     Posted: 06 Aug 2012 at 6:00am
I am getting a divide by zerio error on summed fields how do I get around?
 
(Sum ({@rating1}, {@pldept}) / Sum ({@deptcnt}, {@pldept})) * 100
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Aug 2012 at 6:02am

if Sum ({@deptcnt}, {@pldept})=0 then 0 else

Sum ({@rating1}, {@pldept}) % Sum ({@deptcnt}, {@pldept}))
IP IP Logged
bhar4
Newbie
Newbie


Joined: 18 Jul 2012
Online Status: Offline
Posts: 11
Quote bhar4 Replybullet Posted: 06 Aug 2012 at 6:17am

Thanks that did it.  I was on the right track just couldn't get my syntax right. 

IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 31 Aug 2012 at 7:14am
SET ARITHABORT OFF
SET ANSI_WARNINGS OFF

SELECT ISNULL([Numerator] / [Denominator], 0)


------

SELECT ISNULL([Numerator] / NULLIF([Denominator], 0), 0) AS [Percentage]
FROM [Table1]
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum