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!

Count or DistinctCount?

Status
Not open for further replies.

BradCustom

IS-IT--Management
Oct 5, 2007
296
US
Hi,
I'm using Crystal Reports 2011 with an SQL database.
I'm trying to count the number of Workcenters who's utilization is equal to or below 75%. There are 39 different Workcenters in the report and it's grouped by Workcenter and Transaction Start Date. The Utilization spans over a date range selected be the user. The Utilization is calculated using the following formulas.

@GrandTotWCUtil
if (Sum ({@WCHoursWorkedLine}, {Work_Center.Work_Center}))=0
then 0
else
(Sum ({@WCHoursWorkedLine}, {Work_Center.Work_Center})/{@GrandTotWCCap})*100


@GrandTotWCCap
whileprintingrecords;

Global numbervar newtotalvar;


@WCHoursWorkedLine
DateDiff ('h',{Transaction_Data.Transaction_Start} ,{Transaction_Data.Transaction_End} )


@RTotWCCap
whileprintingrecords;

Shared numbervar WCC;
Global numbervar newtotalvar;

newtotalvar:= newtotalvar + WCC;

@TotWCCap
shared numbervar WCC :=
if (Sum ({@WCHoursWorkedLine}, {Transaction_Data.Transaction_Start}))>10 and
({Transaction_Data.Employee}) in ["396","044","378","049"]
then 16
else 8

Let me know if anyone has any ideas how I can do this. Thanks for your help!!
 
All of those variables and nested formulas make this confusing, but you should be able to write a formula like this (which uses a variable because you used one for the calculation) to be placed in the workcenter group footer:

//{@meetscriterion:
Whileprintingrecords;
Numbervar cnt;

If {@yourfinalvalue} > 0 and
{@yourfinalvalue}<=75 then
cnt := cnt + 1;

Then in the report footer, add a display formula:

//{@displaycnt}:
Whileprintingrecords;
Numbervar cnt;

-LB
 
LB,
I tried your suggestion and it works fine. Thanks for your help!!

Sorry if the post was a little confusing, there are two running totals that I am showing. One for Hours Worked and the second is Hours Available. Then I compare them to determine the utilization. I thought it might help to show all of the formulas I was using.
Brad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top