Thursday, March 29, 2012

Formula to Summarizie records

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!have you tried the
WhilePrintingRecords
Statement to loop through the Datasets.

You dont need the for loop in the formulafield.
Write the Result of your account in a global variable.sql

No comments:

Post a Comment