Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Percents with 0's Post Reply Post New Topic
Author Message
aristeff
Newbie
Newbie


Joined: 09 Feb 2011
Online Status: Offline
Posts: 6
Quote aristeff Replybullet Topic: Percents with 0's
     Posted: 25 Sep 2012 at 10:48am
So I'm trying to come up with a percentage for two colums of data within my report.  I have an picked and return columns and I want to do a percent of what is being returned and then sort by the percent.  I have some totals with zero so when I enter the return/issue*100 it errors because of a divsion by zero.  So I coded around that, but it will not let me us the percent as one of my sorting options.  Here is the current forumla I'm using:
 Sum ({@issued}<> 0 then Abs((Sum ({@returned})/Sum ({@issued})*100)
 
Can anyone offer some help, it would be greatly appreciated.
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 26 Sep 2012 at 7:26am
it won't let you sort because it does not 'know' the results of the formula until the report is rendering, which is too late for sorting.
 
You could get around this if you are using a stored proc, but most don't.
What you might try, is to use a command object to 1 store the id, 2 calculate the percentage. Then you can link to this table in your report, and since the values are now defined before the report starts to print, CR can sort on the command object's percentage.
 
HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 Sep 2012 at 10:47am
Another trick is if you can insert another summarization that gives you the correct data for the order you are looking to achieve and then use the formula to display the data you want to show the end user.
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