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

Year to Year Variance 1

Status
Not open for further replies.

kskid

Technical User
Mar 21, 2003
1,767
US
CR 8.5 on Oracle 8i

My brain is just not functioning today.

I Currently have a report grouped by year with yearly summarized distinct counts. I now need to show a variance from year to year

Example

Year Total Variance
1993 1000
1994 1100 10.0%
1995 1500 36.3%

On a given year, how can I get the previous year's summary to use with the formula

if RptYear = year(currentdate) - 10 then
0
else
RptYear - PreviousRptYear % PreviousRptYear

Any help much appreciated.
 
You can do this using a variable to capture the previous year total.

In Year footer add this formula @previousyear

whileprintingrecords;

global numbervar prevyear:= Sum(amountfield,yearformula)

Then in your group header use formula like
@display variance
whileprintingrecords;

global numbervar prevyear;

If prevyear =0 then 0 else
Sum(amountfield,yearformuala)- prevyear

In report header you will need to initialise variable as zero, to cater for that first record, where you do not have a previous year.

@initialise
whileprintingrecords;

global numbervar prevyear;


Ian Waterman
UK Crystal Reports/Enterprise Consultant
 
Thanks a lot! It worked great
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top