Print Page | Close Window

% formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19419
Printed Date: 01 May 2024 at 10:02pm


Topic: % formula
Posted By: bwsanders
Subject: % formula
Date Posted: 16 Apr 2013 at 6:15am
my % formula that i have working is doing it's job for the details portion but what i'm trying to figure out is how to get it to work on the group totals and footer fields as well.

what i'm using is this:

whileprintingrecords;

if Sum ({field1}, {group}) = 0 then
   0
else
   Sum ({field2}, {group}) * 100 / Sum ({field1}, {group})

it works as it should but at the end of my group i have a totals field that i cannot figure out how to get the percentage on and also the report footer that shows the totals of the report that i cannot figure out the percentage on.

any help would be great!

thank you!!



Replies:
Posted By: joeg1962
Date Posted: 16 Apr 2013 at 6:46am
Make a variable that:
if Sum ({field1}, {group}) = 0 then
   0
else
   Sum ({field2}, {group}) * 100 / Sum ({field1}, {group})

And paste that variable into the group level footer.


Posted By: bwsanders
Date Posted: 16 Apr 2013 at 7:38am
well i made a formula field  "Total %" that i placed into the group footer but it returns "0" instead of a variant of the total records. 


Posted By: joeg1962
Date Posted: 16 Apr 2013 at 7:53am
First thing that comes to mind is 'rounding down to zero'. Beyond that, split the formula up to make sure the denominator is non-zero by only displaying that part of the formula; then display the numerator.
Finally, go back to the full formula.



Print Page | Close Window