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

Main and Subreport comparison

Status
Not open for further replies.

ebstarasia

IS-IT--Management
Mar 9, 2011
62
US
I have two sets of data, in two columns. One column, that is in the main report, is the total YTD volume of a company for 2011, whereas the second column is coming from a subreport that is the same (YTD volume for a company) but for 2010.

What I am trying to do is run a comparison between the two sets of data in percentage. Ultimately, I need to create a third column that shows the percentage increase from the previous year.

What I have been doing is exporting the data to an Excel sheet, creating an extra column and having the percentage calculated with the following formula:

C1 = 2011 Data in cell C1
D1 = 2010 Data in cell D1

=IF(D1=0,C1*1,(+C1-D1)/D1)

or

if D1 = 0
{
C1*1
}
else
{
(+C1-D1)/D1
}

I've read about shared variables that can be passed up to the main report, is that the best route?
 
If it's the same data for two different years, then a Crosstab can handle it. But it would not show percentage increases.

I still think you can drop the subreport, unless there is some complication you have not mentioned. Use Running Totals to accumulate for the two years. Since these are distinct fields, you can easily find the difference. But first use IsNull to test for null values in the Running Total. (The use of Crystal's automated totals is outlined at FAQ767-6524.)

As for shared variables, they are indeed a standard technique and you will probably need them eventually, even if not for this report. This is an example:
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved:={#TotSaved};
SumSaved
And to access it in the main report, create another formula field with
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved

Note that the shared variable is only available in the section after the section which contains the subreport.



[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