Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: When Formatting goes wrong Post Reply Post New Topic
Author Message
VictorFresno
Newbie
Newbie


Joined: 08 Dec 2008
Online Status: Offline
Posts: 8
Quote VictorFresno Replybullet Topic: When Formatting goes wrong
     Posted: 09 Dec 2008 at 11:33am
I'm having some issues with conditional formatting. I've setup an Average Summary(rt_MPGAvg) of Averages(frm_MPG) manually and then would like to have items that are within a particular range (> 133% or < 66%) in Bold Red. But everything seems to have gone awry somewhere and it's not formatting properly. Cry

Here are my formulas that I used to set this up;

Group Header is frm_Reset:
whileprintingrecords;
numbervar i := 0;
numbervar j := 0;


Details is frm_MPG:
whileprintingrecords;
numbervar MPG;
MPG :=
if {FTK_MAIN.QTY_FUEL} > 0
    then {@frm_MilesDiff} / {FTK_MAIN.QTY_FUEL}
else 0


Also in Details is rt_MPG:
whileprintingrecords;
numbervar MPG;
numbervar i;
numbervar i := i + MPG


Group Footer is rt_MPGAvg:
whileprintingrecords;
numbervar i;
numbervar j;
j := i / Count ({FTK_MAIN.FTK_DATE}, {FTK_MAIN.EQ_EQUIP_NO})


The conditional formatting applied to frm_MPG:
EvaluateAfter ({@rt_MPGAvg});
numbervar MPG;
numbervar j;
if MPG  in [(j * .66) to (j * 1.33)]
    then crRed
else crBlack


-and-

EvaluateAfter ({@rt_MPGAvg});
numbervar MPG;
numbervar j;
if MPG  in [(j * .66) to (j * 1.33)]
    then crBold
else crRegular


I've played with other options like using the < & > than operators, but I still run into the same issue.  So, I ran some tests to determine what my calculations were producing and it seems like j is growing incrementally. How can I get it to produce the same quantity as the final rt_MGPAvg number produced in the group footer?

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 10 Dec 2008 at 6:53am
How are they different?  What are you seeing?  Is the formatting correct, just the numbers are off?
 
I am assuming that the your numbervar are shared, otherwise each formula can't 'see' the correct values of i, j, and MPG.
 
Thanks
IP IP Logged
VictorFresno
Newbie
Newbie


Joined: 08 Dec 2008
Online Status: Offline
Posts: 8
Quote VictorFresno Replybullet Posted: 10 Dec 2008 at 8:29am
I think Crystal uses Global as default var, so that should be shared between formulas. The formulas for i & j appear to be working, but when I do the comparison between MPG & the percentages of j, then it's all over the place. It appears that j grows incrementally in each detail line. For example; j = 14.93 in the Group Footer, but when I take it back to the detail line in the conditional formatting, then the amount changes.

Is there a way to make a variable output into a static number for the comparison?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 11 Dec 2008 at 6:55am
I don't know about the basically storing one variable, but I would do to check would be to write another formula, one for the detail line that would basically calculate the j for a line.  Something like:
 
local numbervar z := 0;
if {FTK_MAIN.QTY_FUEL} > 0 then 
    z := {@frm_MilesDiff} / {FTK_MAIN.QTY_FUEL};

z := z / Count ({FTK_MAIN.FTK_DATE}, {FTK_MAIN.EQ_EQUIP_NO});
 
z
 
The last z is probably not needed, I just like to know what I am displaying for sure.  But something like this on every line of detail should allow you verify if your total j is reasonable.
 
Hope it helps
IP IP Logged
VictorFresno
Newbie
Newbie


Joined: 08 Dec 2008
Online Status: Offline
Posts: 8
Quote VictorFresno Replybullet Posted: 11 Dec 2008 at 9:33am
Yup, ran this formula and found that Z grows incrementally, like a running total, with each detail line.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 11 Dec 2008 at 9:57am
I would look at {@frm_MilesDiff} or MPG, everything else seems right
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