Print Page | Close Window

Formula to Summarizie records

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Writing Code
Forum Discription: .NET 2003 programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=305
Printed Date: 02 May 2024 at 11:33pm


Topic: Formula to Summarizie records
Posted By: thtang
Subject: Formula to Summarizie records
Date 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 ( mailto:%7b@NumberPacking - {@NumberPacking })) + {Table.CasePackingDesc} + Chr(13);
);
temp

It basically return the same CasePackingDesc for 2 times.

Any idea on this will be greatly appreciated, thanks!




Replies:
Posted By: hilfy
Date Posted: 12 Mar 2007 at 11:02am
I would use a couple of formulas:
 
mailto:%7b@IsBottle - {@IsBottle }
If {Table.CasePackingDesc} = 'Bottle' then 1 else 0
 
mailto:%7b@IsCase - {@IsCase }
If {Table.CasePackingDesc} = 'Case' then 1 else 0
 
On your Total line,  put a Sum of mailto:%7b@IsBottle - {@IsBottle } next to a text block with the word "Bottle" and a Sum of mailto:%7b@IsCase - {@IsCase } next to the word "Case".
 
-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