Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: Formula to Summarizie records Post Reply Post New Topic
Author Message
thtang
Newbie
Newbie


Joined: 10 Mar 2007
Location: Hong Kong
Online Status: Offline
Posts: 1
Quote thtang Replybullet Topic: Formula to Summarizie records
    Posted: 10 Mar 2007 at 2:52am

Hi, I have a report which will obtain following set of data, for example:

NumberPacking CasePackingDesc  Amount
2               Bottle         32kg
1               Bottle         10kg
2               Case           10kg
------------------------------------
TOTAL           3 Bottle       52kg
                2 Case

I have problem generating the TOTAL of 3 bottle and 2 case. I would like to write a formula field to return the result, but I don't know how to loop though all the records in the record sets.

Here is the formula field I have done so far:

Local stringVar temp := "";
Local numberVar i;
for i:= 1 to DistinctCount({Table.CasePackingDesc}) step 1 do
(
    temp := temp + CStr (Sum ({@NumberPacking})) + {Table.CasePackingDesc} + Chr(13);
);
temp

It basically return the same CasePackingDesc for 2 times.

Any idea on this will be greatly appreciated, thanks!

IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 12 Mar 2007 at 11:02am
I would use a couple of formulas:
 
If {Table.CasePackingDesc} = 'Bottle' then 1 else 0
 
If {Table.CasePackingDesc} = 'Case' then 1 else 0
 
On your Total line,  put a Sum of {@IsBottle} next to a text block with the word "Bottle" and a Sum of {@IsCase} next to the word "Case".
 
-Dell
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.