Print Page | Close Window

Global Summation

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=915
Printed Date: 05 May 2025 at 8:17am


Topic: Global Summation
Posted By: redboan
Subject: Global Summation
Date Posted: 22 Jun 2007 at 11:44am
Hello,

I'm having one small issue.  I have 13 subreports, and in these subreports, I have a formula that adds up certain data fields.  However, I need a formula in which it adds up all these fields globally but have been unsuccessful to do so.

If anybody could shed some light on this, that would be fantastic.

Thanks,
Adrian



Replies:
Posted By: hilfy
Date Posted: 22 Jun 2007 at 2:49pm

You could use a set of shared variables - one for each subreport.  Declare them and set their initial values to 0 in the main report.  Something like this:

BeforeReadingRecords;
Shared NumberVar sub1 := 0;
Shared NumberVar sub2 := 0;
...
Shared NumberVar sub13 := 0;
 
In each subreport, you would use the corresponding shared variable that's declared in the main report.  So in Subreport 1, you would have something like this:
 
Shared NumberVar sub1;
sub1 := sum({table.field});
 
Repeat for each variable and subreport.
 
In your main report, you would then have another formula that would add all of the values of these shared variables together:
 
Shared NumberVar sub1;
Shared NumberVar sub2;
...
Shared NumberVar sub13;
 
sub1 + sub2 + ... + sub13
 
Put this final formula on the report to display your total.
 
Note that you MUST declare the variables in EVERY formula where they're used.  It's the only way that Crystal knows how to use them.
 
-Dell
 


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window