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

getting running total formula result in group header

Status
Not open for further replies.

maas

Programmer
Sep 3, 2009
148
BH
Hello All,

I am having difficulties while getting the value of the running total forumla in Group Header 1.

Here is the structure of my report:
Group Header 1: CCY
Group Header 2:Type

@reset Group Header
whileprintingrecords;
numbervar sumpct4;
if not inrepeatedgroupheader then
sumpct4 := 0;

Group Header 3A: Deal No
Group Header 3B: Deal No (subreport to get the {@amount} for each deal)
I will pass the end_date from the main report to subreport and I will get the sum(amount) for each deal between date (1-1-2008) to end_date. The sum will be as a shared variable to the {@amount} formual in the main report.
Details:
Deal No, {@amount}, {@Price}, {@market}, {@Total_Market}

{@Price}: if {table.price} = 0 then
100
else {table.price}


{@market}: if Type <> "DEP" then
({@amount}*{@Price})/100
else
{@amount}

{@Total_Market}:{@market}+ {@Price}


Running formula to get Total_market: Details section
whileprintingrecords;
numbervar sumpct4 := sumpct4 + {@Total_Market};
numbervar grtotal4 := grtotal4 + {@Total_Market};

Group Footer 3B: Deal No
Group Footer 3A: Deal No
Group Footer 2:Type
In this group I am placing a running total formula:

whileprintingrecords;
numbervar sumpct4;

Group Footer 1: CCY


Report Footer:
@grand_Total
whileprintingrecords;
numbervar grtotal4;

Now, i want this @grand_total formula result to be shown in Group Header 1: CCY.

I tried to insert a subreport at the beginning which it is a copy of the main report, but I did not get the coorec t result because I am getting the {@amount} from a subreport and in crystal I can't insert a subreport in an existing subreport.

Can you please help to get this total above.

Thanks and regards
 
You're writing your own formulas and fields to do a job that Crystal can do automatically. Also a running total 'runs' along with the printing, and will typically have a zero value in the group header or report header. Try displaying it and this will be clear.

Summary totals are done at an earlier stage in Crystal's cycle and so the header can show them. But in your case the totals are conditional, which makes it more complex.

Define a formula field saying something like
Code:
if {table.price} = 0 then
100
else {table.price}
Put @HoldPrice in the detail line, right-click and create a group summary total for it. This will be placed in the group footer but can be moved to the group header and still be correct. And so on with the other totals.

The use of Crystal's automated totals is outlined at FAQ767-6524.



[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
so, only by using the running totals I can get the result?
 
Only a summary total can be shown in the header. You can use summary totals for data fields or form formula fields, as I suggested.

If that won't work, the other method is to use a subreport at group-header level. This could display the result you want, though the result will not be available to the main report until the section after the section that holds the subreport.

Does that help?

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
It didn't work.

I am having a subreport in the main report which is getting the {@amount} value. In this case, I can't get the value of it in the subreport.

 
What didn't work? Are you talking about another subreport?

Subreport values are passed to the main report using Shared Variables, but are not there until the next section. They can be passed back using subreport links, but note that these create selection statements in the subreport that need to be checked and maybe removed.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top