Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Count distinct false 1 instead of 0 Post Reply Post New Topic
Author Message
Randin
Newbie
Newbie


Joined: 30 Jan 2014
Location: United States
Online Status: Offline
Posts: 3
Quote Randin Replybullet Topic: Count distinct false 1 instead of 0
     Posted: 31 Jan 2014 at 8:28am
Hello CR friends,

Report Background:
Purpose:
To see which work orders belong to which company
Groups:
Group 1: Case Owner
Group 2: Case Status
Group 3: Case Category

Calculated fields
If {@company} = "1" then {Case ID}
If {@company} = "2" then {Case ID}
etc..

These calculated fields are summarized on each group header with a distinct count so it should give me a breakdown of which companies cases are under which owner and which status like such:

Owner     TotalCount   Company1   Company2   Company3
Owner1            7               0               0                 7
Owner2

etc...

Problem:
However, the count distinct of {Case ID} is giving me 1's where it should be 0 (see the red values above) but it works fine where the value should be 1 or higher.

The closest thing I've found is when I switch my calculated fields to
If {@company} = "1" then 1
and do a sum, it works fine, except when there are duplicate records. I can't rely on Select Distinct Records because a SQL join results in several duplicate Case ID's. If you think it would be easier to change my query than the calculation, I'd be happy to divulge my frustrations with that :)

Thanks,
Randin
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Jan 2014 at 8:43am
you can use a cross tab which should be easier.
 
to do what you want for the calculated field would be to use a NULL trick
create a formula field called NULL and leave ti empty
 
in your calculated fields use
 
If {@company} = "1" then {Case ID} else {@NULL}
If {@company} = "2" then {Case ID} else {@NULL}
 
You could also use Running Totals
IP IP Logged
Randin
Newbie
Newbie


Joined: 30 Jan 2014
Location: United States
Online Status: Offline
Posts: 3
Quote Randin Replybullet Posted: 31 Jan 2014 at 10:03am
Hey thanks for the quick reply. Since I already had the report built out I just did the null trick and it worked perfectly. Huzzah!
I'll be sure to look into cross tabs and running totals, as this is surely not going to be my last report in CR and every little trick seems to help along the way.

Cheers & thanks!
Randin
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum