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

How to display the Maximum of a count formula

Status
Not open for further replies.

careymw

IS-IT--Management
Oct 8, 2010
41
US
Using Crystal Report 2008
I've created a report to display the total number of calls per Trunk Group and the total number minutes (duration) of calls per trunk group. Now I'm trying to display the maximum calls (during the specified date range) per trunk group.(peak trunks)

Trunk Group Calls Duration Peaks trunks
MCI 15000 8050 139
Sprint 987456 19987 180
Cox 78965 1087 29

I have to count the number of trunks per trunk group per day. I have done this but I can figure out how to only use the maximum or biggest number.
I tried a group sort option but it doesn't like my count formula. I've been looking at doing a variable to use whileprintingrecords. Any suggestions?
 
So you want to use the calls summary, correct? Are the call numbers shown above based on an inserted summary or is it a formula? If a formula, please show the content of the formula.

-LB
 
I have 3 groups in my report
Trunk Group
Call Date
Trunk

I have this formula at the details @Count
if not(isnull({TRUNK.TRKNUM})) then 1 else 0

I have this formula at the group by date @grpcount
count({@count}, {DTRUNK.UDAY})

Then I am using the summary data per trunk group....

So for trunk group MCII would see

MCI 15000 8050
5/1/2011 119
5/2/2011 104
5/3/2011 139

I only want to use the 139 as it is the most trunks used for MCI.

 
Your {@grpcount} formula is incorrect. The count of a conditional formula is the number of times it executes, not the number of times it meets the condition. You should be using:

sum({@count},{DTRUNK.UDAY})

OR, you could use:

count({TRUNK.TRKNUM},{DTRUNK.UDAY})

...since the null trknums won't be counted.

To get the maximum, you can use a variable, but you would need to display the result in the trunk group group footer, NOT the group header, and then just suppress the group header and details section.

Create these formulas:

//{@reset} to be placed in the TrunkGroup group header #1:
whileprintingrecords;
numbervar maxtr;
if not inrepeatedgroupheader then
maxtr := 0;

//{@accum} to be placed in the {DTRUNK.UDAY} group #2 header or footer:
whileprintingrecords;
numbervar maxtr;
if count({TRUNK.TRKNUM},{DTRUNK.UDAY}) > maxtr then
maxtr := count({TRUNK.TRKNUM},{DTRUNK.UDAY});

//{@display} to be placed in the TrunkGroup Group Footer #1:
whileprintingrecords;
numbervar maxtr;

-LB
 
Thank you for the explaination on the count vs sum on a contional formula.

These variable formulas worked great. I hadn't even heard of the function inrepeatedgroupheader.

Thank you for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top