Print Page | Close Window

Tricky Sums

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1133
Printed Date: 04 May 2024 at 5:54am


Topic: Tricky Sums
Posted By: yggdrasil
Subject: Tricky Sums
Date Posted: 07 Aug 2007 at 4:17am
I have a report with 2 groups. In the group footer of the inner group I have several shared variables that conditionally sum up from the detail lines. 
 eg
mailto:%7b@sumA - {@sumA } is 1 if a detail field is A and 0 if it isn't, (there are similar formulae for other types), and the summary formula is:-
 
WhilePrintingRecords;
shared numbervar senAcount;
if mailto:%7b@sumA - {@sumA } > 0 then
senAcount := senAcount + 1
else senAcount
 
That all works fine in GF1. But then I have to show it in GF2, and at this point it adds the last @sumA on again, making the totals one out. 
How can I take the figures in GF1 and put them unaltered in the fancy design bit of the report in GF2, which does an awful lot of other things as well, and is what I am being asked to produce.
 
Please don't suggest a subreport, I am already using one to get the details, and they can't be nested, which is why I am doing all this explicitly.
 
 



Replies:
Posted By: jkwrpc
Date Posted: 07 Aug 2007 at 8:05am

You should make certain that the formula in the group footer simply returns the variable and does no further calculations.

It might look like this:

---------------------------
WhilePrintingRecords;
shared numbervar senAcount;
senAcount;
-----------------------------
 
Hope this helps
 
Regards,
 
John W.
http://www.CustomReportWriters.net - www.CustomReportWriters.net  


Posted By: yggdrasil
Date Posted: 08 Aug 2007 at 12:17am
I had tried that. It didn't work. It still adds the extra one in again.


Posted By: jkwrpc
Date Posted: 08 Aug 2007 at 3:49pm

I would recommend that you take another look your report design.  Somewhere you are having one additional pass. It is quite likely in your Groups and how the report iterates through them. When I have run into the problem this where I usually find the solution.

Kind of hard to help much more without the layout.   
 
Typcially I see in my reports a layout like
 
Group1Header 
Group2Header
Details
Group2Footer
Group1
 
If you are able what happens if you run the calcs inside of Group 2?
 
Perhaps Dell or Brian have a better recommendation.
 
Regards,
 
John W.
http://www.CustomReportWriters.net - www.CustomReportWriters.net
 
 


Posted By: hilfy
Date Posted: 08 Aug 2007 at 4:30pm
Instead of using your second formula, create a "Summary" field to sum the first formula at each group level where you want it.
 
To get to the Summary wizard, go to the Insert menu and select Summary or click on the button with a sigma (angular capital E) on it.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: yggdrasil
Date Posted: 09 Aug 2007 at 3:19am
Thanks for all your help. I have gone all through it again, and got a workround. It was ok within the inner group GF2, and I was resetting all the sums to zero for each outer group GF1. So now I have added the reset formula in again  in a suppressed outer group footer GF1a  before showing the data in a GF1b footer.



Print Page | Close Window