Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: SUM or Count in Group Footer Post Reply Post New Topic
Page  of 2 Next >>
Author Message
KJAZ
Newbie
Newbie


Joined: 11 Aug 2010
Online Status: Offline
Posts: 7
Quote KJAZ Replybullet Topic: SUM or Count in Group Footer
     Posted: 11 Aug 2010 at 3:15pm
Hi,
 
I'm new to Crystal Reports. I've developed some simple reports using XI, but am now struggling with one particular report.
 
DATA: State,College,Subject,Target%,Grade%,Grade%,Grade%
For example:
WA  CollegeA  Science  65%  70%  50%  70%
WA  CollegeA  Math      50%  60%  60%  60%
WA  CollegeB  Science  60%  70%  70%  72%
 
I need to report by State (used Group1) the total number of Colleges (used Group2 & DISTINCTCount) and the number of colleges which have failed their target in any subject. The above example would report 1 State containing 2 Colleges, 1 of which failed (i.e CollegeA failed in Science).
 
Here's my problem, I've created a formula used in Details that counts the number of fails. It only counts up to 1 because I only need to report on failing colleges not subjects. 
 
LOCAL numbervar FAILCOUNT;
if FAILCOUNT = 0 then (if {Sheet1_.PASSFAIL} >= {Sheet1_.Threshold} then FAILCOUNT := 1 else FAILCOUNT := FAILCOUNT);
 
In Footer2, I then MAX (FAILCOUNT) which returns a 0 or a 1 for each college. I now want to SUM or Count the MAX(FAILCOUNT) and can't find out how to do it.
 
I'm sure the above method isn't the most efficient :-) so any suggestions/advice most welcome.
 
Thanks,
K
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Aug 2010 at 4:00am
I prefer to use Running Totals.
Create a RT as:
Name=Failed
Field to sumamrize=College (or College ID if you have it)
Type=DistinctCount
Evaluate=Use a formula
insert your formula here for what constitutes a failure probably something like
table.Grade<table.target
Reset=Group1
place in GF1
 


Edited by DBlank - 12 Aug 2010 at 4:00am
IP IP Logged
KJAZ
Newbie
Newbie


Joined: 11 Aug 2010
Online Status: Offline
Posts: 7
Quote KJAZ Replybullet Posted: 12 Aug 2010 at 7:45am

Things are so much easier when you how to do them Smile

Works a treat, Thanks.
 
Although, this does now lead to a follow-on question - I now want to SUM my RT of 'fails' in the RF. What's the best way to do this, use a formula, another RT?
 
Thanks again, your help is much appreciated
K
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Aug 2010 at 8:08am
create another RT that is the exact same but make reset=never and place in Report footer
IP IP Logged
KJAZ
Newbie
Newbie


Joined: 11 Aug 2010
Online Status: Offline
Posts: 7
Quote KJAZ Replybullet Posted: 12 Aug 2010 at 9:24am

of course!

Thank you so much

IP IP Logged
KJAZ
Newbie
Newbie


Joined: 11 Aug 2010
Online Status: Offline
Posts: 7
Quote KJAZ Replybullet Posted: 06 Sep 2010 at 1:52pm
Hi,
As with all well-defined user requirements, I now need to enhance my report. Despite numerous attempts I can't figure out how to design this new item.

My original report looks something like this:

State:   No. of Colleges:    No. Colleges with Failure in any subject:

I now need to add a stacked bar-chart showing No. failed colleges and No. successful colleges by state.

I'm unable to use a running total for successful colleges, because a failing college can have many successful subjects which are also included in the RT. I wanted to use a RT formula that set a value to true only when a subject was a pass. Despite my best newbie efforts it 'automatically' sets it to false for a subject fail.

I have tried adding a formula field which subtracts the failures from the total no of colleges, this gives me the successful college count. However, I can't then use this formula as a data field in the chart.

Any suggestions very welcome,
K
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Sep 2010 at 4:39am

There are a few ways to do this but probably the easist would be to use a distinctcount of the colleges at the state group levl and subtract the failed college rt

ditinctcount(college,state) - #Failed


Edited by DBlank - 07 Sep 2010 at 4:40am
IP IP Logged
KJAZ
Newbie
Newbie


Joined: 11 Aug 2010
Online Status: Offline
Posts: 7
Quote KJAZ Replybullet Posted: 07 Sep 2010 at 11:25am
Sorry DBlank I should have been clearer in my post. I have already created a formula (#Success) which uses Distinct Count of Colleges by State and then subtract the #Fails RT. This works fine.

My problem is that this formula (#Success) is not then available to use as a data field in Chart Expert?

Thanks for taking the time to look at this,
K
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Sep 2010 at 11:38am
even to be added as a "Show value"?
IP IP Logged
KJAZ
Newbie
Newbie


Joined: 11 Aug 2010
Online Status: Offline
Posts: 7
Quote KJAZ Replybullet Posted: 07 Sep 2010 at 11:57am
Not available as a Show Value, my RT fields are available as are some other formula fields that I was experimenting with. I wondered if it was because the formula uses an RT in its calculation?

Thanks again,
K
IP IP Logged
Page  of 2 Next >>
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