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

Detail level totals not rolling up properly

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
Crystal 8.5

Groups from Highest (Outer) to Lowest (Inner)
Group1 - Division
Group2 - Region
Group3 - LeaseHeader
Group4 - LeaseDetail

Detail is suppressed, everything prints in LeaseHeder footer. We have 2 kinds of leases, operating and finance. I have defined a RunningTotal variable AccDep which accumulates LeaseDetail information and resets on change of Group3.

For a finance lease NetVal is a calculation involving fields contained in the LeaseHeader record. An operating lease has a NetVal equal to a LeaseHeader field minus the accumulated depreciation (#AccDep) as follows:

NetVal formula field definition
If FinanceLease Then
LeaseHeader.Field1 + LeaseHeader.Field2, etc
Else
LeaseHeader.Field - #AccDep

Everything prints properly in the LeaseHeader footer and NetVal is correctly calculating for both lease types.

The problem I am having is that I cannot create another RunningTotal field. @NetVal does not show up in the list of selectable report items. If I try to do it with a formula field then I get an error that says it can not be created which I believe pertains to the fact @NetVal already has a running total field in it.

Here is what I would like to do:

RunningTotal for RegionNetVal definition
Sum @NetVal
Evaluate at change of Group3 (LeaseHeader)
Reset on change of Group2 (Region)

Any ideas and/or suggestions would be much appreciated!

Have a great day!

j2consulting@yahoo.com
 
Try creating three formulas:

//{@reset} to be placed in the Group #2 Header:
whileprintingrecords;
numbervar regnetval := 0;

//{@accum} to be placed in the Group #3 footer:
whileprintingrecords;
numbervar regnetval := regnetval + {@netval};

//{@display} to be placed in the Group #2 footer:
whileprintingrecords;
numbervar regnetval;

-LB
 
Thanks lbass, that is what I am currently doing, but I was hoping to avoid using variables. In 8.5 there is no way to keep track of them that I know of except opening up your formula variables and examining them individually.

As an aside, here is a technique I use to minimize the number of variables I have to define in cases such as this. Using this method I only have to create the accumulator and footer formula variables.

I also change the background color of anything using Global variables so I can tell at a glance which ones reference a Global variable. In the format properties I then set the conditional background color to the following so it has no impact on the report:

WhilePrintingRecords;
White

Detail accumulator in Group3 footer in above code

WhilePrintingRecords;
Local NumberVar locNet;
Global NumberVar DivNet;
Global NumberVar RegNet;
// Code to calculate locNet
locNet := some calculation
DivNet := DivNet + locNet;
RegNet := RegNet + locNet;
locNet; // if it needs to be printed

Group2 footer - Reset here to save creating separate reset

WhilePrintingRecords;
Global NumberVar RegNet;
Local NumberVar locNet := RegNet;
RegNet := 0;
locNet;

Group1 footer - Reset here to save creating separate reset

WhilePrintingRecords;
Global NumberVar DivNet;
Local NumberVar locNet := DivNet;
DivNet := 0;
locNet;


Have a great day!

j2consulting@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top