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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display string formula reset the cumulative percentages

Status
Not open for further replies.

jehanzebn

Programmer
May 28, 2001
244
Afternoon all,

I have a report with Crosstab which calculates number of orders against number of days. The same report shows two types of percentages (1: Normal and 2: Cumulative). The problem I am having is with Cumulative percentage being reset on the next page.

Report Footer:
[Crosstab]


Days - Jobs - Percentage - Cumulative percentage

To get the cumulative percentage I used a formula under Display String of the Normal Percentage field.

Code:
Whileprintingrecords;

Numbervar x:=Currentfieldvalue;
Numbervar c:={@TotalJobs-CancelledJobs};
Numbervar v:=((x/c)*100);

Numbervar gTot:=gTot+v;

if gTot > 100 then "100.00%"
else 
totext(gTot,2)+"%"

Then I created another formula reset which I placed on Report Header,
Code:
Whileprintingrecords;
Global Numbervar gTot:=0;

The report runs fine until the next page, the cumulative record gets reset and starts over again.

For example

Page 1
Cumulative percentage
20%
30%
45%
60%
80%
98%

Page 2
Cumulative percentage
0.1%
2.0%
2.1%

Initially I thought it was because of the reset I setup on Report Header, which then I took off however it did not made any difference to the cumulative percentage.

All the rest (Days,Jobs,Percentages) are correct only the cumulative which gets reset on the next page.

Any ideas?

Regards

Jehanzeb
Crystal Reports 2008
Visual Studio 2008
Informix Database
 
Perhaps this is the answer to my question??

Bug with multi-page cross-tabs and global variables
Thursday 4 December 2008 @ 12:40 am

Some of you may have played with a technique that I have written about in the past. It is where you use a variable to create running totals within a cross-tab. These running total values can then be used within the cross-tab or even outside the cross-tab.

But I recently heard from a user who was having trouble whenever the cross-tab went over a page break. His variables would reset to zero on the new page and he thought it might be a bug in v10. So I did some testing and found that this behavior occurs in all versions, right up to CR 2008. Whenever a cross-tab goes over a page break it resets any variables it is using, even though the variable is global. The reset goes back to the value of the variable at the beginning of the split section. Usually this means a reset to zero. However in cases where the variable already has a value before the cross-tab section starts, it resets to that value.

There must be a bug or design flaw in the way the split pieces of a cross-tab are processed. Unfortunately, I could find no way to prevent the reset.

Thanks to Peter Lapic for pointing out this bug to me.

Source []

Regards

Jehanzeb
Crystal Reports 2008
Visual Studio 2008
Informix Database
 
Well I tried using Mock Crosstab but that does the same thing, as long as it is on the single page it works fine but as soon as you click to the next page the percentages gets reset.

Regards

Jehanzeb
Crystal Reports 2008
Visual Studio 2008
Informix Database
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top