Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight a particular column value in Crystal Report

Status
Not open for further replies.

siddu1234

Programmer
May 21, 2008
5
US
Hi,
I have a crystal report which displays columns with values like this

TransTypeID Productcode StartTime TimeDifference
1 c0001 5/6/2004 6:30PM 1.00
1 c0002 5/6/2004 6:31PM 2.00
1 c0003 5/6/2004 6:33PM 1.00
1 c0004 5/6/2004 6:34:pM 1.00
1 c0001 5/6/2004 6:35:pM
Here TimeDifference is a formula field which calculates the timeDiff the adjacent transactions in minutes.For example
the timediff between first and second record is 1 minute while between two and three is 2 minutes.I need to highlight in red the TimeDifference column values which are above the average of Timedifferences column value.I tried using Highlight Expert by right clicking TimeDifferencecolumn value. But it only allows me to specify a static value.(like field value greater than 2.00, 3.00 etc) .How can we specify a average value here.please help.
 
You would have to save the report as a subreport and then insert it in the report header of the original report (assuming you comparing to the report average). You can suppress all sections WITHIN the subreport, but the subreport itself or the report header. You can also format the subreport to "suppress blank subreport" and format the report header to "suppress blank section."

In the subreport, calculate the average by using variables like this:

//{@accum} to be placed in the detail section:
whileprintingrecords;
numbervar sumdiff := sumdiff + {@TimeDifference};
numbervar cnt := cnt + 1;

//{@average} to be placed in the subreport footer:
whileprintingrecords;
numbervar sumdiff;
numbervar cnt;
shared numbervar avediff := sumdiff/cnt;

Then in the main report you can use a formula like the following to color {@TimeDifference}. Right click on it-> format field->border->color->background->x+2:

whileprintingrecords;
shared numbervar avediff;
if currentfieldvalue > avediff then
cryellow else crnocolor

-LB
 
That should have said "but NOT the subreport itself or the report header."

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top