Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: conditional addition of field's data Post Reply Post New Topic
Author Message
vikas.sun
Newbie
Newbie
Avatar

Joined: 19 Aug 2010
Online Status: Offline
Posts: 3
Quote vikas.sun Replybullet Topic: conditional addition of field's data
     Posted: 19 Aug 2010 at 7:54am
Hello everybody :)
i have records as
fdNo FDAMT ENCFDNO ENCAMT 
101  100        1                40                      
102  500        2                400
101  100        3                60                      
102  500        4                100
____________________________
         600                        600
--------------------------------------
i want 600 as summation of both the columns FDAMT and ENCAMT.
is it possible to sum the FDAMT field on unique FDNo field basis ???? 
thanks in advance.
IP IP Logged
sukhveer
Newbie
Newbie


Joined: 18 Aug 2010
Online Status: Offline
Posts: 22
Quote sukhveer Replybullet Posted: 22 Aug 2010 at 10:50am
Insert a Subreport and Group on FDAMT.
Add a summary on FDAMT at grouplevel.
Sum({Data_.fdamt}, {Data_.fdamt})
Add a RunningTotal to count the no of records at each group.
#RTotalCount
Add a formula @distinctSum to calculate the distinct totals.
WhilePrintingRecords;
numbervar distinctSum;
distinctSum := distinctSum + Sum ({Data_.fdamt}, {Data_.fdamt}) / {#RTotalCount};
 
Now, using a shared variable you can pass this value to the main report!
Not sure, if this is the best solution.
IP IP Logged
vikas.sun
Newbie
Newbie
Avatar

Joined: 19 Aug 2010
Online Status: Offline
Posts: 3
Quote vikas.sun Replybullet Posted: 23 Aug 2010 at 12:02am
i was trying to add distinctSum as forlula field but when i save it with code:
WhilePrintingRecords;
numbervar distinctSum;
distinctSum := distinctSum + Sum ({Data_.fdamt}, {Data_.fdamt}) / {#RTotalCount};
results in the following error message:
the summary / running total field could not be created. 
please help me out. might be i could not create subreport rightly.
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