Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Group Summing Issue Post Reply Post New Topic
Author Message
kaifiser
Newbie
Newbie


Joined: 15 May 2009
Location: United States
Online Status: Offline
Posts: 18
Quote kaifiser Replybullet Topic: Group Summing Issue
     Posted: 26 Jun 2009 at 10:14am

Hello,

I have 3 drillable groups and can’t figure out why Groups 2 and 3 are not returning all of the data in their tables.

I have 3 db queries linked together but the results being returned are only the top record from each of the queries.  Group 1 works fine because there is only one field per State;

But Group 2 only grabs the top County from each State; Group 3 only grabs the first City from each County, etc., etc.,etc.. I need to sum all of the data in these Groups  to show a total by County, City and not just the first record for each County.

 

The linked queries return all of the data fine and (I believe) are linked together correctly.

Am I missing something really easy here?  

Thanks for your help

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 Jun 2009 at 11:29am
Is the data now appearing or just your numbers are wrong?
If you numbers are wrong sounds like you are using running totals and placing them on headers. They must be used on footers (or detail rows).
Summary functions can be used on headers (SUM, COUNT, DISTINCTCOUNT, etc.).
IP IP Logged
kaifiser
Newbie
Newbie


Joined: 15 May 2009
Location: United States
Online Status: Offline
Posts: 18
Quote kaifiser Replybullet Posted: 26 Jun 2009 at 11:42am
Thanks for your reply.  The numbers are wrong; Group 2 is only picking up the first line from the data set, not all of the others.  I don't have running totals, only a SUM field that I specified in the query. 
 
Query 1 asks for STATE, GROSS SALES, NET SALES
Query 2 asks for STATE, COUNTY, GROSS SALES, NET SALES
Query 3 asks for STATE, COUNTY, CITY, GROSS SALES, NET SALES
 
I have the sales summed properly in the 3 queries.
 
I have the 3 groups set up the same way; the difference is that the Group Sum isn't working; it is only pulling the 1st record from Query 2 and Query 3 - so instead of seeing 5 Counties of sales per State, I am only seeing one.  Am I making sense?  Please let me know if I can elaborate further..
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 Jun 2009 at 12:27pm

Sorry, but I am a bit confused. Your descriptiion here is making me think you may be trying to do all of your calculations (including SUMS) in a SQL query and then display that info including the SQL sums in Crystal.  If I am understanding this correctly you really only need to bring in query3 as your data fields without any summary functions and let crystal do the calcualtions for you.

Is this on the mark or am I missing something?
IP IP Logged
kaifiser
Newbie
Newbie


Joined: 15 May 2009
Location: United States
Online Status: Offline
Posts: 18
Quote kaifiser Replybullet Posted: 26 Jun 2009 at 12:45pm

Thanks again - real close but I am not explaining myself well enough.    I might be able to just take away the SUMS in the SQL but because the data is transaction data, I can't group them the way the user wants.  I was told (by the Lead Engineer) that the only way to get this data to roll-up at all is to do the 3 separate queries by STATE as a link.  My issue is that I am not getting the proper SUM in the GH sections.  Group 1 shows FLORIDA with sales of 50,000, from one line of data; but at a County level it might actually be  50 lines that roll-up into the State with an amount of 100,000.  The SUMS make no sense to me, but I know for a fact that Crystal is not summing up the GH sections in Group 2 and 3; it is only pulling the first line of data from the result set.....and I need it to SUM, no matter how goofy the data looks..

I hope this explains it well enough, if not, I can post a reply on Monday with a full example if necessary.

 

Thanks again for all of your help.

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 Jun 2009 at 1:01pm

You know your data better than I do but I can try and help Smile

Basically if you just palce a DB field on a header it will do what you describe and show you the value of that first row that meets that group condition.
If you create a Crystal summary of a field and place that on the header it will give you a SUM of all of that field from all rows that meet the group condition. 
If you are tyring to get the gross sales or net sales as summed per group level try the SUM process in crystal.
click on the sigma (insert SUmmary) button
choose the net sales (or gross sales) field to summarize.
calculate as a SUM
location at Group3
it will insert it on the footer but you can move it to the group3 header.
Is that the correct value?
if so repeat for Group2 group 1 and grand total.
IP IP Logged
kaifiser
Newbie
Newbie


Joined: 15 May 2009
Location: United States
Online Status: Offline
Posts: 18
Quote kaifiser Replybullet Posted: 29 Jun 2009 at 5:47am

Hey DBlank thanks again,

Nope that doesn't work in my case.  When I insert a SUM in the RF and move it into the GH section, it is then summing up all of the data for the group, not just the Counties per GH1 (STATE)  STATE selection in my Group 2 field.  Basically, if I select Group 1 (STATE), it sums up perfectly; if I drill into Group2 (COUNTY), it then only grabs the first record for the COUNTY data set and the SUM function SUMS up all of the COUNTIES for that STATE, not the individual COUNTY...

 

EXAMPLE:

GROUP 1 (query 1)  STATE (the SUM per STATE is fine)

If I drill into a STATE, it then becomes GROUP 2 (query 2) COUNTY - here is where only the first record from my query 2 gets pulled in the field (I am expecting to see 3 fields); if I do a SUM, it adds up all COUNTIES from Florida (approx 50 records)....

I am flummoxed..  I hope I have explained this well enough.

Thanks again, 

IP IP Logged
kaifiser
Newbie
Newbie


Joined: 15 May 2009
Location: United States
Online Status: Offline
Posts: 18
Quote kaifiser Replybullet Posted: 29 Jun 2009 at 11:39am
Hey DBlank,
I figured it out somehow - I ended up putting in a subreport using Query 3 and magically all the rows of data appeared.  While I had tried this before, for some reason it worked this time.
Once again, thanks for your attention and your help; it is much appreciated.
Thanks...
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