Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: DISTINCTCOUNT in Group, need total in header Post Reply Post New Topic
Author Message
Lindsay
Newbie
Newbie


Joined: 02 May 2011
Online Status: Offline
Posts: 3
Quote Lindsay Replybullet Topic: DISTINCTCOUNT in Group, need total in header
     Posted: 02 May 2011 at 1:45pm
Hi, We have reports that have been running for years in Crystal Reports 10.  I'm used to working in Microsoft Reporting Services 2005, but need to modify a Crystal Report today.  Basically in a group header, I am doing a DISTINCTCOUNT, which is working correctly.  I need a total in the header.  How do I do this?   


(HEADER)  TOTAL:               NEEDS TO BE 15

(GROUP) Wave  Location  Distinct Item Count
              1         1             1
              1         2             6
              1         3             7
              1         4             1
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 03 May 2011 at 3:12am
I don't think that you can, at least not simply, since you can't aggregate an aggregate...ie you can't get the SUM(DISTINCTCOUNT({table.field}, group))...at least I pretty sure that you can't.  You could sum this value using shared variables, perhaps running totals, but it would have to be in the footer, not the header, as CR would need to read the data to get the answer, and it hasn't done that yet.
 
The one way around this, when joining to the tables directly would be to use a subreport...you could duplicate all grouping logic, place the summing in a formula, populate a shared variable and then access the shared variable in the main report.
 
If you are using a stored proc to drive your report, just create a new column and populate it...way simpler and is my preferred method of gathering data for reports, any reports.
 
HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 May 2011 at 4:19am
another trick wold be to concantenate the 2 items together into one string and do a distinctcount of that formula field.
 
IP IP Logged
Lindsay
Newbie
Newbie


Joined: 02 May 2011
Online Status: Offline
Posts: 3
Quote Lindsay Replybullet Posted: 03 May 2011 at 7:54am
Thank you both for responding! 

I have created a concatenated field and placed it in my group header.  I thought I would be able to then right-click on the field and select "Edit Summary..." and continue on from there as I have done with a few other fields in the header.    However, instead of Edit Summary... I see "Edit SQL".  How can I get the option to summarize my new field?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 May 2011 at 7:57am
place the formula field in the detail section to verify it is working
do an insert summaryusing the formula field set as a distinctcount at the report footer
move that to the report header


Edited by DBlank - 03 May 2011 at 7:58am
IP IP Logged
Lindsay
Newbie
Newbie


Joined: 02 May 2011
Online Status: Offline
Posts: 3
Quote Lindsay Replybullet Posted: 03 May 2011 at 1:27pm
Ahhh this worked like a charm!!!!  Thank you so much for your help.  You've made my day!  Clap

Lindsay
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