Avatar of wshcraft70
wshcraft70
Flag for United States of America asked on

Subreport in Crystal passing data and need to build an average in Main Report

Subreport formula:

 if({CallDetail.InternalNum})  > 600 and ({CallDetail.InternalNum}) <=700 then
0 else {CallDetail.Duration}

I've added the subreport in the DETAILS section on my MAIN REPORT

I need to now calculate an average for everything that was passed in my REPORT FOOTER

Is this possible?  If so, could someone provide complete details on how to do this?

Thanks in advance..
Crystal Reports

Avatar of undefined
Last Comment
wshcraft70

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mike McCracken

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
wshcraft70

ASKER
I've got this on a group and I need the record count to be reset for my average per group record..

Where would I add this?

Visuals are awesome..  ;)

Thank you soooooo much..
Mike McCracken

Put the display/avverage calculation formula in the group footer

In the group header add this formula to reset the values
WhilePrintingRecords;
Shared NumberVar RecCount;
Shared NumberVar DurationTotal;
RecCount := 0;
DurationTotal := 0;
""
wshcraft70

ASKER
I cannot get the average Talk Time to calculate..  For some reason, the group rec count doesn't seems to be resetting..  Below is what I have..  Do you see where I've gone wrong?

Currently:

Report Header:

WhilePrintingRecords;
Shared NumberVar RecCount;
Shared NumberVar DurationTotal;
RecCount := 0;
DurationTotal := 0;

Sub Report:

whileprintingrecords;
shared numbervar RecCount;
shared numbervar DurationTotal;
Local NumberVar CallDuration;

if({CallDetail.InternalNum})  >= 600 and ({CallDetail.InternalNum}) <700 then
     CallDuration := {CallDetail.Duration}
else
    CallDuration := 0;
if CallDuration > 0 then
  RecCount := RecCount + 1;
DurationTotal := DurationTotal + CallDuration;
CallDuration


Group Footer:


WhilePrintingRecords;
Shared NumberVar RecCount;
Shared NumberVar DurationTotal;

If RecCount = 0 then
    0
Else
   DurationTotal / RecCount;
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
wshcraft70

ASKER
I dropped the Report Header down to the Group Header and I'm now GOOD TO GO..  :D

Thanks for everything..