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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Summerizing a Formula 1

Status
Not open for further replies.

CalgaryCR9

Technical User
Aug 12, 2005
80
CA
Crystal Reports 9

My report has two groups. Group 1 being "Company.company_id". Group 2 is "service_call.service_call_id"

In group footer 2 I have the following correctly working formula {@callcount_1}:
if ({@convert_resolved_number})>0
then 1

It's not relevant but {@convert_resolved_number} is the following formula:

NumberVar TotalSec := datediff("s",NthLargest (1, {@Open Time}, {SERVICE_CALL.SERVICE_CALL_ID}),NthLargest (1, {@resolved }, {SERVICE_CALL.SERVICE_CALL_ID}));

I require a summary formula to be placed in group footer 1 (service_call.service_call_id) of {@callcount_1}.

Example data:
Service call id @callcount_1
1234 0
5678 1
8905 0
4445 1

Total 2

The distinctcount function gives me 4 which is not what I'm looking for. I've been staring at this too long and now need perspective from others. Any help would be greatly appreciated.
 
Since the formula is in a group section, use a formula in a variable, as in:

numbervar MyCount;
if ({@convert_resolved_number})>0
then MyCount:=MyCount+1

Make sure that you use:

numbervar MyCount:=0

as a formula in the group 1 header to reset it for each.

-k

 
I got it working. Thanks synapsevampire & a posting I read from lbass.

My reset formula:
// reset_call_count
whileprintingrecords;
numbervar sumcount:=0

My modified @callcount_1 formula in group footer 2 (service_call.service_call_id):
numbervar sumcount;
if ({@convert_resolved_number})>0
then sumcount:=1

My modified @total_call_count formula:
//{@total_call_count} to be placed in the company group footer (group 1);
whileprintingrecords;
numbervar sumcount;

My ending formula to obtain an average located in group footer 1 (company.company_id):
whileprintingrecords;
numbervar sumcount;
if ({@sum})>0
then {@sum}/{@total_call_count}
 
Your formula isn't accumulating though. I would change {@callcount_1} in group footer 2 to

whileprintingrecords;
numbervar sumcount;
numbervar compcnt;

if ({@convert_resolved_number})> 0
then sumcount := 1;
compcnt := compcnt + sumcount;
sumcount; //so that sumcount is displayed here

Use your first reset formula in the Group #2 header.

Add another reset formula to the group #1 header:
whileprintingrecords;
numbervar compcnt := 0;

Then change the average formula to:

whileprintingrecords;
numbervar compcnt;
if {@total_call_count} > 0 then
compcnt/{@total_call_count}

Not sure what's in {@total_call_count}, but I'm assuming that's giving you the correct count.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top