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

Distinct Count Conditions

Status
Not open for further replies.

CIBS

Technical User
Nov 15, 2007
73
GB
Hi

I am trying to create a report based on the job number and the status. The report is set up and is running fine. What I want to do is count all the distinct job numbers but I want it to exclude certain job no. based on the status filed

Also I should mention that the status feild is a sum (@Status) that contains the following calculation

if {Status.Status} = 1
Then "UK"
else
if {Status.Status} = 2
Then "Scotland"
else
if {Status.Status} = 3
Then "Ireland"
else
if {Status.Status} = 4
Then "Walse"
else
if {Status.Status} = 5
Then "Non-UK"

An example of my table as it stands is below

Job No. Status
56781 Walse
56854 Walse
57543 UK
57543 UK
67976 Scotland
78543 Ireland
78543 Ireland
78841 UK
79005 Non-UK
79006 Non-UK

Distinct Count = 8

What I want is to do is a distinct count but do not want to include "Non-UK" Job No.'s so I should get a count of 6

I have used a command to not display the "Non-UK" but it still counts them in the distinct job no.'s

the suppression command I have in place is

Status.Status in ["Non-UK"]

Please Help, As I am going going to be creating a cross-tab summary of this report

Kind Regards

Stephen
 
Summary counts will include all records for a group, or for the whole report. You need a Running Total, which can include a condition.

If you're not already familiar with Crystal's automated totals, see FAQ767-6524.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Why not exclude status = "Non-UK" from the report? You could use a record selection formula like:

{status.status} <> 5

If you can't do this, you can do the following. Create a formula {@Null} by opening and saving a new formula without entering anything. Then create a formula like this:

if {status.status} <> 5 then {status.jobno} else tonumber({@Null}) //remove the tonumber if job no is a string

You can insert a distinctcount on this or use this formula in a crosstab and insert a distinctcount summary on it.

-LB
 
I have manged to do it using the below formula

if {THREAD_EVENT.THREAD_EVENT_TYPE} >1
then
DistinctCount ({CALL.CALL_NUMBER},{THREAD_EVENT.START_DATE_TIME})

Cheers anyway
 
Unless I'm missing something, your approach will not work correctly. Your formulas says, if the event type is > 1 show the distinctcount of ALL call numbers for the group based on the event start date time.

Your formula should be:

if {THREAD_EVENT.THREAD_EVENT_TYPE} > 1 then
{CALL.CALL_NUMBER} else
tonumber({@Null})

Then you can insert a distinctcount on it at the start time group level.

-LB
 
Yeah Sorry, The original example that I gave was just a sample my manager then decided he wanted it grouped by dates as well (Go Figures) so I changed "NON-UK" to 1 and "UK" to 5 so now the report distinct count everything above 1 and is grouped by there start date.

This formula does seem to work as running the report for the last 20 days (using a date range parameter)and checking twice and seems to be correct.

But thanks for your help.
 
It will only work correctly if there is no "1" in the start date group. If you have the report grouped by the UK/NON-UK and then by the start date, you will get the correct number in the UK groups, but if you don't have this, I think you will only sometimes get the correct number (when there happens to be no "1" in the group).

-LB
 
There is only a start date group.

There is a group above that but isn't the status one
 
I take my hat off to you, your way work a lot better then mine. I'm having fun though experimenting

Cheers for all you help
 
This report is now working spot on but how do I get it to work in a cross-tab (To create a summary) as currently things are not tallying up. the coloums are dates and rows is the users name and i want the same distinct count but now in the cross tab. I can't get the totals to tally up at all.


Please help
 
Don't know what is not "tallying up" for you. Please show a sample of what you are getting (and explain in what report section), and what you are expecting to see.

Using the crosstab should be simple. Just use the last conditional formula I showed you above as the summary field, and insert a distinctcount.

-LB
 
Below is the table of users, the days them selves work fine it's the totals that are wrong. for example look at Ray, Z

14/12/2007 15/12/2007 16/12/2007 17/12/2007 18/12/2007 19/12/2007 Total
PAUL, B. 1 0 0 1 0 0 2
PAUL, M. 3 0 0 1 0 0 4
PAUL, S. 6 0 0 3 7 0 16
PAUL, W. 1 0 0 1 4 0 6
RAM, P. 1 0 0 6 2 1 10
RAY, Z. 2 0 0 3 3 0 6
RICHARD, S. 2 0 0 2 3 0 6
RICK, R. 0 0 0 2 1 0 3
ROBERT, G. 3 0 0 0 4 0 7
SHAB, K. 5 0 0 4 5 0 13
SIMON, L. 1 0 0 0 0 0 1
STEVE, C. 0 0 0 5 1 0 6
STUART, G. 4 0 0 5 7 0 16
TIM, M. 8 6 1 4 1 1 20
TONY, T. 1 0 0 0 0 0 1
TONY, W. 3 5 2 3 3 1 17
Total 88 15 10 127 152 30 408
 
Forget to mention that as the summary I am doing a distinct count on the formula you provided
 
Please post the exact formula you are using for your summary field. Also, please clarify whether {CALL.CALL_NUMBER} can appear in multiple days or whether it is unique to one datetime. My guess is that the distinctcount for the total is simply less because there are cases where the same call number appears in several days, but would only be counted once across all days for the total.

-LB
 
Hi

That is correct the call number can be across a number of days.

My Rows are person.person_Familyname
My Column is Call.Call_Receive_Date
the Summary is Distinct Count {@DCount} - This is a formula of what you provided me
 
The crosstab is showing the correct results if the call number is used across days. Are you are expecting to see the numbers add up to the total?

-LB
 
You are better off creating a manual crosstab then.

-LB
 
How do you create a manul crosstab in CR
 
A 'Mock Crosstab' or Manual Crosstab is something that looks like a Crosstab, but in fact you define each column yourself, normally as a running total. This would need to go in the report footer, because running totals count as the reports 'run' and they will not be complete until then. Crystal should have included an example along with the Crosstabs.

You can save a little time by doing a paste to a dummy report, changing the name and then pasting back.

Each running total will count the record if it was within the criteria

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top