Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Supressed Section causing duplication of Data Post Reply Post New Topic
Author Message
Lamy
Newbie
Newbie
Avatar

Joined: 14 Jan 2014
Online Status: Offline
Posts: 13
Quote Lamy Replybullet Topic: Supressed Section causing duplication of Data
     Posted: 15 Jan 2014 at 6:38am
G'day,
Nice to meet you all.

Background
I am working on a report in Crystal Reports XI (w/all update packs) on Win 7 64 bit.

The report uses 1 group based on a members SSN. The group header has text block labels for the columns below.

The detail section has the data in rows. Some users have multiple (Health) coverage types so the rows can repeat.

The group footer holds some text and data and below that a sub-report that is built identically as above but with the members dependents and their coverage. Members can have no dependents, dependents with no coverage or dependents with coverage.

Data comes from my own SQL commands in both the report and sub-report. Data is based on an SSN parameter & a report date parameter. I have 3 SQL commands under the report, one gets a dependent count, one gets a dependent ID and one is all the data on the member. All 3 use the same parameters and all 3 SQL are made up of 3 joined tables. (I have used different combinations of joins but the result is always the same as mentioned below). The sub-report is one SQL with the same parameters and same 3 joined tables but just dependent data.

The sub-report/group footer section should be suppressed when there are no dependents or dependents with no coverage.

Issue
The report works fine with dependents, no dependents/no coverage shows an empty "Table". So I check the suppress box and add a formula, I have tried both:
If DistinctCount ({depCount.DepCount}) <> 0 Then
True
Else
If IsNull({depID.DEPENDENT_ID}) Then
True
Else
False;
originally, or figuring in both cases there is no Dependent ID so I changed it to just:
If IsNull({depID.DEPENDENT_ID})
Both of these work and suppress the section as needed.

However both cause a duplication of data for the member.

Example:
My test member when not suppressed has one row of member data & two blocks of dependent data.

With suppression added, his one row of data becomes 3 rows, apparently the original row plus the original row repeated for each dependent (member plus 2 dependents).

In a worse case the member has 3 rows of data and 5 dependents which becomes a total of 18 rows for the member (member 3 rows plus 3 rows per 5 dependents).

Once again, remove the suppression formula and the member has the correct number of correct rows.

Both with & without suppression, the dependent data always shows correctly. I cannot figure out why suppression would cause a duplication of member data and why it duplicates reflecting the number of dependents.

Any ideas?
Thank You, Migwetth, Gunalche’esh, Ha’w'aa, Danke

Kyle
Annalyst/Programmer

"If you shoot Wolves to save the Moose, then you shoot the Moose, you must be crazy or from Alaska"
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Jan 2014 at 6:54am

Usually this is a join issue.

I will guess here that you are not using any fields from either depcount or depid tables when it gives you the correct set of values. as soon as you use one of those tables it changes your data set.
To test the theory have it without the suppression where it is OK. IN preview mode just drag and drop any field from depcount or depid onto the report canvas and watch your data set (row count) change.
Does this happen?
IP IP Logged
Lamy
Newbie
Newbie
Avatar

Joined: 14 Jan 2014
Online Status: Offline
Posts: 13
Quote Lamy Replybullet Posted: 15 Jan 2014 at 7:09am
Good Call!

depCount is being used, but when I dragged depID over the rows multiplied.

So if I understand you right, I need to change the joins for that command.

Will do.
Thank You, Migwetth, Gunalche’esh, Ha’w'aa, Danke

Kyle
Annalyst/Programmer

"If you shoot Wolves to save the Moose, then you shoot the Moose, you must be crazy or from Alaska"
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Jan 2014 at 7:29am

you need to join the commands together in the crystal (or better yet change your report to use one command with 2 sub queries).

Crystal does not automatically "enforce" joins. 

As soon as you use a field it enforces a join (or if no join exists uses a Cartesian result).

The likely issue here is that you are using 3 separate commands to gather data and thinking of them as separate data sets (maybe like in reporting services?). However, if you use the values form the commands in the report it is "joining' the results together. If you try to avoid that by not actually creating a join it will give you a Cartesian result which is every possible combination of all 3 results together.



Edited by DBlank - 15 Jan 2014 at 9:12am
IP IP Logged
Lamy
Newbie
Newbie
Avatar

Joined: 14 Jan 2014
Online Status: Offline
Posts: 13
Quote Lamy Replybullet Posted: 15 Jan 2014 at 8:14am
Hmm, OK, that explains the other issue of why Toad shows the data correctly and CR does not.I wrote the queries in Toad and it works fine, then duplicated in CR, so I never really thought of the Joins as the issue.

Got it!
Thank You, Migwetth, Gunalche’esh, Ha’w'aa, Danke

Kyle
Annalyst/Programmer

"If you shoot Wolves to save the Moose, then you shoot the Moose, you must be crazy or from Alaska"
IP IP Logged
Lamy
Newbie
Newbie
Avatar

Joined: 14 Jan 2014
Online Status: Offline
Posts: 13
Quote Lamy Replybullet Posted: 15 May 2014 at 12:57pm
LOL I forgot about this but had the same issue again... so do a search and find this one that is exactly what I have and behold... It is mine.

So thanks all for the help the second time too. Fixed it once again.


Edited by Lamy - 15 May 2014 at 1:00pm
Thank You, Migwetth, Gunalche’esh, Ha’w'aa, Danke

Kyle
Annalyst/Programmer

"If you shoot Wolves to save the Moose, then you shoot the Moose, you must be crazy or from Alaska"
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