Print Page | Close Window

Counting Data

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=21435
Printed Date: 05 May 2024 at 8:11am


Topic: Counting Data
Posted By: JediSkipdogg
Subject: Counting Data
Date Posted: 16 Apr 2015 at 1:44pm
I'm semi new to Crystal Reports so I'm hoping someone can help.  I am using version 10 and am pulling data from a large database to make a monthly report of statistics for the company I work for (it's a police department). 
 
I have a main report that requests dates and then I have created 6 subreports in it that pass the date request from the main to each of the sub reports.  On each of the subreports I am trying to do nothing more than give a count of the numbers between the desired date ranges. 
 
One subreport I am counting how many traffic citations we have issued and filed with one of three different courts and how many charges have occurred on each citation (some could be cited for speeding and improper lane change at the same time.)  What I'm trying to present is as follows...
 
 
                  Citations            Charges
Court A          15                       20
Court B          95                      105
Court C          35                       65
Total            145                      195
 
The easy solution would be a group however our system does not seperate the data for which court it was filed with, therefore I'm trying to make a formula do it.  The issue I'm having is Citations is showing the exact same number as Charges even though I have two different formulas.  I currently have...
 
For the total fields I have....
 

Total Cite: If ({P_CITE_TAB.CITE_DTE} = ({?@CiteFrom} to {?@CiteTo})) Then 1 Else 0

 

Total Charge: If ({P_CITE_TAB.CITE_DTE} = ({?@CiteFrom} to {?@CiteTo}) And {P_CITE_TAB.CITE_CD} = ["TC","W"] And ({P_STATUTE_TAB.STATUTE_ID} like ["3*","4*"])) Then 1 Else 0

 

I am them using the Summary option and selecting Count this Summary By "Sum."  Both columns produce the same numbers.

 

The STATUTE_ID tells me what court it goes to along with the CITE_CD.  The Total Charge column comes up correct, but the Total Cite charge shows the exact same numbers all the way down as the total charge. 

 

Thoughts?

 



Replies:
Posted By: DBlank
Date Posted: 17 Apr 2015 at 11:36am
is your sum at the group level or the report level?
SUM(formula)
or SUM(formula, groupfield)


Posted By: JediSkipdogg
Date Posted: 17 Apr 2015 at 7:25pm
I'm going to say at the Report (sub report) level because I'm not using groups since wasn't sure what main category to group by since we don't enter data based on the court. The court is determined by the CITE_CD and STATUTE_ID.


Posted By: DBlank
Date Posted: 20 Apr 2015 at 5:56am

Edited as an error in original response



Posted By: clbammel
Date Posted: 23 Apr 2015 at 3:44am
I'm new to the forum, but have quite a lot of experience in Crystal and doing these sorts of totals. The first thing to ask, is "Are your formulas correct?". Have you placed the formula into a detail line and run it to see if it is giving you the expected results? Look at each line. Are you seeing a 1 where you expect to and a 0 where you expect to? You can leave the line in the report and just suppress it later so it won't be visible.

Secondly, I'd have all the Courts in the same subreport. You can have a formula CourtA, CourtB, and CourtC, which will test each citation. In this scenario, two of the formulas should have a 0 value and one should have a 1 value on each line. Then have 3 summaries at the end: SumCourtA, SumCourtB, and SumCourtC.



-------------
cb


Posted By: JediSkipdogg
Date Posted: 24 Apr 2015 at 3:48pm
I have not tried that clbammel. I will see that that generates the next time I work and let everyone know. Thanks.



Print Page | Close Window