×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Count or DistinctCount?

## Count or DistinctCount?

(OP)
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!!

### RE: Count or DistinctCount?

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

### RE: Count or DistinctCount?

(OP)
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.

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!