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!

How to get percentage value

Status
Not open for further replies.

jschill2628

Programmer
Nov 3, 2009
156
US
I have two subreports:
1. for my Baseline
({IRSCLAIM.CREATE_DT} in DateTime (2009, 07, 01, 00, 00, 00) to DateTime (2011, 06, 30, 00, 00, 00))

2. one for my 3MonthAvg
({IRSCLAIM.CREATE_DT} in dateserial(year(currentdate),month(currentdate)-3,1) to date(year(currentdate),month(currentdate),1)-1)

My main report has a moving time frame
({IRSCLAIM.CREATE_DT} in dateserial(year(currentdate),month(currentdate)-9, 1) to
date(year(currentdate),month(currentdate),1)-1)

What I want to get is a percentage based on the Baseline and the 3MonthAvg
=(3MonthAvg- Baseline)/ Baseline

My problem is I am not sure how to do this in Crystal.

Thanks
 
jschill,

I am not 100% sure I follow what specifically it is your are intending to do - but I do believe that [blue]Shared[/blue] variables are the solution to your problem. With these variables you can pass data back and forth from SubReports to the Main Report and back again.

There are plenty of examples on the site as to people using them, but the "standard" format for setting up a variable is as follows:

Each Variable needs a "Reset" at the top of the report (or in the header of a group upon which a reset is needed), an "accumulation" / variable set, and a display (as warranted).

{@VariableName_Reset}
Code:
WhilePrintingRecords;
Shared NumberVar VariableName:=0;

{@VariableName_Set}
Code:
WhilePrintingRecords;
Shared NumberVar VariableName;

VariableName:= *SomeCalculation*;

{@VariableName_Display}
Code:
WhilePrintingRecords;
Shared NumberVar VariableName;

My apologies for not being able to provide a specific solution, but hopefully this helps you get started and/or another member of the Tek-Tips group can assist with the specifics.

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top