Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: sum of subreport in primary report Post Reply Post New Topic
Author Message
futureinfuture
Newbie
Newbie


Joined: 16 Jul 2009
Online Status: Offline
Posts: 5
Quote futureinfuture Replybullet Topic: sum of subreport in primary report
     Posted: 17 Jul 2009 at 12:25pm
Hi there;
 
It seems that Crystal can not do the sum() functionality for the field which is from subreport.
 
In the primary report, I have many rows with RSN number. For each RSN number, I got the a total fee for each RSN number. These total fee are showing on each row of main report. At the bottom of primary report, I need to get Grand Total fee from all RSN number. This grand total fee should be sum of the data obtaining from subreport.
 
However Crystal report only allows me to choose the field in the field list of Primary report. The subreport is not the field in the list, I can not add those fee value to show in the primary report.
 
Maybe I have to create database function to get the first fee for each row, then, get sum in primary report.
 
Any idea to get those done?
 
Jean
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Jul 2009 at 1:00pm

You can use a shared variable.

In the SUb report make it = your "total fee"
In the main report make it = sub report and then SUM that.
IP IP Logged
futureinfuture
Newbie
Newbie


Joined: 16 Jul 2009
Online Status: Offline
Posts: 5
Quote futureinfuture Replybullet Posted: 20 Jul 2009 at 11:01am
Hello;
 
Thanks for your help.
 
 
 
To make it simple, I tried to create a shared variable for passing data from subreport to main report
 
Since I am not allowed to sum (formula), e,g, sum({@mainformula), I
calcualte the grand total from subreport. detailed steps are:
 
1. In subreport, create formula called subformula, the shared valiable = grand total
 
WhilePrintingRecords;
Shared CurrencyVar myTotal :=Sum ({Command.SUM(AB.FEEAMOUNT)})
 
2. In main report, created a formula called mainformula

WhilePrintingRecords;
Shared CurrencyVar myTotal;
myTotal
 
3. I put this mainformula on the main report underneath of subreport. I got the total fee from last row , not grand total fee.
 
What went wrong? Please help.
 
Jean
IP IP Logged
Richard100
Newbie
Newbie
Avatar

Joined: 13 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 1
Quote Richard100 Replybullet Posted: 13 Nov 2009 at 5:03am
Jean,
 
Did you ever manage to resolved this?... I'm having exactly the same problem.. I can get the information passed across from the subreport but like you I only get the total from the last subreport row.
 
ie
Subreport produces 1, 5 and 2 on seperate rows
I want total to equal 8, but it returns 2 everytime.
IP IP Logged
futureinfuture
Newbie
Newbie


Joined: 16 Jul 2009
Online Status: Offline
Posts: 5
Quote futureinfuture Replybullet Posted: 14 Nov 2009 at 2:17pm
No. I never get the problem solved. If you have the anwser, please let me know.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum