Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

totaling from a distinct count using While formula

Status
Not open for further replies.

chuchuchui

Technical User
Dec 23, 2004
33
US
I'm using Crystal XI on Windows 2000 server with IBM UniVerse.

I am trying to total a columns which for some reason has a number of duplicates. The formula is mostly from Ken H's site.

First I created a running total named LiabBICSL with a distinctcount on PA_Coverages_VehicleNo.VEHICLENO; Evaluate for each Record; Reset on change of group Group #1: Policies.Policies_ID

I then went on to create three formulas:

1: To count everything and total it; this is in the Details section, which is supressed.

NumberVar Prior;
NumberVar Liab;
WhilePrintingRecords;
if {#LiabBICSL} = Prior + 1 //which indicates a first record for this customer
then Liab := Liab + {PA_Coverages_VehicleNo.LIABPREM};
Prior := {#LiabBICSL}; //store the current count to compare with next record
Liab;

2: To Display the total in the group footer section. The .01 is just because the numbers are stored multiplied by 100; I don't know why.

NumberVar Liab;
WhilePrintingRecords;
Liab * .01;

3: Reseting the variables to 0 in the group header which is supressed.

NumberVar Liab;
NumberVar Prior;
WhilePrintingRecords;
Liab :=0;
Prior :=0;

It almost works except for some reason or another it doesn't seem to add the first record so if there should be four distinct records is totals only three of them. Even when I have displayed the Prior variable it seems to miss the first record. Any ideas?
 
I can't recreate your problem. I did a mock report with your formulas, and it worked fine. Maybe try removing them from the report canvas and adding them again.

Also, ordinarily "whileprintingrecords" is the first line of a formula that uses that evaluation time. I don't think this is the problem though.

-LB
 
Thanks lbass, well after verifying the formula wasn't the problem I went back and tested our system as it turns out it was a problem with that particular database. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top