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!

Totaling problem with formulas 1

Status
Not open for further replies.

ganjass

Technical User
Dec 30, 2003
154
GB
Hi I have a report that has a lot of running totals. I have succesfully got the correct totals for most of the columns but i am getting a problem with 3 fields, which are formula fields. I have tried the 3 formula technique, but the results i am getting are either far too high eg 686,756,885.04 when i am expecting 64,000 or zero. I have tried moving the the initilisation formula about but no joy. I am using crystal 8 and, I have 3 groups set up as so:

GH1:Sundry group
GH2:Date of Entry based on (if isnull({sundry-info.si-date@6}) then {debt.dt-datinstr} else {sundry-info.si-date@6})

GH3:debt code
GF2: Running Totals
GF3: Totals of Running Totals

Thanks in advance
 
You didn't provide enough information about what you are trying to do (formulas, sample data, ...).

Cheers,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
I agree with Ido, which are wrong, the Running Totals or the Totals of Running Totals?

The Running Totals need to be reset at the GH2 level, and then you would add values at the detail level (most likely).

The Totals of RT's would not be reset.

Show what it is that you're totaling, where you're doing so, and try to test by limiting the rows so that it's easy to determine what the variance is.

-k
 
ok guys point taken, well the formulae for the 2 columns in question are:

@total: Sum ({@Office}, {@DOE}, "monthly")+
Sum ({@Littlewoods}, {@DOE}, "monthly")+
Sum ({@Field Payments}, {@DOE}, "monthly")

@commission: {@Total}*({@Commission}/100)


these columns as do the others, appear in the second group footer

Data is as so:

Total Total Commission
5957.66 2383.06
12256.41 4902.56
6274.17 2509.67
8045.34 3218.24
7747.84 3099.14
4985.00 1994.00
3084.00 1233.76
2531.77 1012.71
2671.44 1068.58
5366.39 2146.78
1746.99 698.76
266.08 106.43
0 0.00

Totals ( using 3 formulas)
686,756,885.04 274,702,754.02

 
you have a bunch more formulas that you have not shown

@Office, @LittleWoods, @Doe, @FieldPayments

Show everything

If you are using a 3 formula sum then it is quite simple .

this formula for totals is in the Group 2 footer??? I assume the data you display is the result of these @total and @Commission formulas

Well you don't show the formula for totaling the sums together.

@Init (placed suppressed in the Group 1 header;

WhilePrintingRecords;
if not inRepeatedGroupHeader then
(
NumberVar TotalAmt := 0;
NumberVar TotalCommission := 0;
);
" ";

In the Group 2 footer

@CalcSums (suppressed in Group 2 footer)

evaluateAfter ({@Total});
evaluateAfter ({@Commission});
NumberVar TotalAmt;
NumberVar TotalCommission ;

TotalAmt := TotalAmt + {@Total};
TotalCommission := TotalCommission + {@Commission};


And display formulas for TotalAmt and Total COmmission

@DisplayTotalAmt (in Group 1 footer)
WhilePrintingRecords;
NumberVar TotalAmt;
TotalAmt;

@DisplayTotalCommission (in Group 1 footer)
WhilePrintingRecords;
NumberVar TotalCommission ;
TotalCommission ;


That should do it easy enough


Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Thanks for that that worked a treat, i've never used the nRepeatedGroupHeader function before, and now that i have its eased my headaches!! as a point of reference why did you include the ""; after the brackets in the @Init formula

Cheers
 
It came up in another post.

I think it may be version specific since it has never been a problem before but some people were saying that Crystal was demanding an ELSE condition with the formula in the form


If not inRepeatedGroupheader then
Something;

SInce this formula is placed on the report, Crystal wants to assign a value to the formula....but it cannot if the result is FALSE. So by adding the "": at the end the formula always is assigned a null so there is no problem for Crystal.....that is my spin on it anyway.

It is kinda like using a formula to define just an array.

@Init
WhilePrintingRecords;
StringVar Array test := [ "","",""];

Is not legal since the result of a formula cannot be an array.

However, this is legal

@Init
WhilePrintingRecords;
StringVar Array test := [ "","",""];
"";




Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top