Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Cross Tab - with Percent column Divide by zero Post Reply Post New Topic
Author Message
Tonyak74
Newbie
Newbie
Avatar

Joined: 24 Apr 2013
Online Status: Offline
Posts: 28
Quote Tonyak74 Replybullet Topic: Cross Tab - with Percent column Divide by zero
     Posted: 14 Aug 2015 at 3:44am


I am working on a cross tab report.
I am trying to display CT Open, CT Closed and the percentage of closed. By month and by WO type

I have a formula for CT Open
if {WOCR.WOKey}>1 then 1 else 0

Formula for CT Closed
if {WOCR.Closed} then 1 else 0

The counts are showing up right

I created an additional formula
Also created a formula {@0}:
whilereadingrecords;
0

I have added the summary fields in the crosstab, and add sum of {@0} as my last summary

Then in preview mode, I select sum of {@opened} ->right click->format field->suppress->x+2 and enter:
whileprintingrecords;
numbervar open := open + currentfieldvalue;
false

Select {@closed}->right click->format field->suppress->x+2 and enter:

whileprintingrecords;
numbervar closed := closed + currentfieldvalue;
false

Then select the 3 column ({@0}->right click->format field->display string->x+2 and enter:

whileprintingrecords;
numbervar open;
numbervar closed;
totext(closed%open,2)+"%"

Since I have zeros in many fields I am getting Divide by zero errors when adding the last formula to the display string.

Any assistance would be appreciated.
Thanks

IP IP Logged
Tonyak74
Newbie
Newbie
Avatar

Joined: 24 Apr 2013
Online Status: Offline
Posts: 28
Quote Tonyak74 Replybullet Posted: 14 Aug 2015 at 9:19am
I was able to get it!Big%20smile
For Column 3 I used the following formula in the display string...
whileprintingrecords;
numbervar open;
numbervar closed;
if open <> 0 and closed <> 0 then
totext(closed%open,1)+"%"
else "N/A"
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