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!

Summing Group Totals 1

Status
Not open for further replies.

wdubya

MIS
Aug 27, 2010
3
US
Greetings,
I am new to Crystal. I am trying to sum laon types into 2 total groups. Header 1 contains the account name. Header 2 is an ownercode within the account. I put the reset CurrencyVar AmountA;
AmountA := 0; in header 2 and the display
CurrencyVar AmountA; in Footer 2.
I want to put AmountA and AmountF totals in footer 2.
I have tried using formula fields, group expert and running total fields to no avail. My results are zero or I get the total amount for the ownercode in one field.
My code is as follows:
If loantype in(a,b,c) Then
AmountA := AmountA + {tableamountfield}
Else
AmountF := AmountF + {tableamountfield};
I put the loantype and the tableamountfield in the details section. I used the help section for running totals fields (line by line) and that didn't even work. I out this coe in a formula in the evaluae section. Obviously, I can put this somewhere and it will work. Any help would be appreciated.
 
First off, if you want the variables to keep their value beyond the scope of the formula, the variable definition needs to have 'shared' in front of them (in all formulas).

i.e.
Shared CurrencyVar AmountA; (Also could be written Shared CurrencyVar AmountA := 0;)
 
I think you can instead just create two formulas like this:

//{@abc}:
if {table.loantype} in ['a','b','c'] then
{table.amount}

//{@notabc}:
if not({table.loantype} in ['a','b','c']) then
{table.amount}

Place these in the detail section and then right click on each and insert sums at the group level and/or the report level.

-LB
 
Thanks lbass but I am still confused.
In the detail section I have
Shared CurrencyVar AmountA;
Shared CurrencyVar AmountF;
If {Table.Loantype} <> ("A";"B";"C","D" )
Then AmountA;:
If {Table.Loantype} in ("A";"B";"C","D" )
Then AmountF:

In the Group Footer Section I have 2 fields

Shared CurrencyVar AmountA;
AmountA: = AmountA + {Table.Amount};
and

Shared CurrencyVar AmountF;
AmountF: = AmountF + {Table.Amount};
(I've tried multiple sum commands with no luck)

My table has 4 loan types to accumulate into either AmountA or AmountF and then a total for both(copied from another report) totext(Maximum(lastfullmonth))
Maximum

My report prints the 3rd record in both AmountA and AmountF fields
The table amount sum field for AmountA and AmountF is now the 4th Table.Amount value

Report results:
Loantype(s) A-10 B-25 Y-30 X-40
Group Footer Section
AmountA 30
AmountF 30
AmountA and AmountF 40

Nothing is getting accumulated. I cannot find any documentation on summing variables ?!
Any sense of direction you can share would be appreciated.
Thanks
 
I don't think you need variables for this. You are making it more complicated than it needs to be. Why not try my suggestion?

-LB
 
I think it is the wrong way to go, but if you insist on using variables, your four formulas should look like this:

//{@accum} for the detail section:
whileprintingrecords;
CurrencyVar AmountA;
CurrencyVar AmountF;
If not({Table.Loantype} in ["A","B","C","D"])Then
AmountA := AmountA + {table.amt} else
If {Table.Loantype} in ["A","B","C","D"] Then
AmountF := AmountF + {table.amt};

//{@reset} for the group header #2:
whileprintingrecords;
CurrencyVar AmountA;
CurrencyVar AmountF;
if not inrepeatedgroupheader then (
AmountA := 0;
AmountF := 0
);

//{@displayAmountA} for the group footer #2:
whileprintingrecords;
CurrencyVar AmountA;

//{@displayAmountF} for the group footer #2:
whileprintingrecords;
CurrencyVar AmountF;

While you could use "shared" instead of or in addition to "whileprintingrecords", usually "shared" is used to share variables between a main and subreport.

-LB
 
Thanks LB ! I went with your initial resolution and it worked ! Thanks for your patience
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top