Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a formula to do a count

Status
Not open for further replies.

ssiroky

Technical User
Sep 4, 2003
17
US
I am trying to do a count of crime reports (incidents.inc_rep_number) by the crime offense (offense.offense_code). I have already created a group of offenses. Now I need to do a count for Aug. 2001, Aug. 2002, and Aug. 2003. The end result should look like this:

Aug. 01 Aug. 02 Aug. 03
Robbery 23 45 26
Murder 2 6 4

Do I need to create variables, or is there a simpiler way to get this accomplished? Thanks in advance for any help.
 
hi
Create formula
@Count

count({incidents.inc_rep_number},{offense.offense_code}

cheers

pgtek
 
hi
Create formula
@Count

count({incidents.inc_rep_number},{offense.offense_code})

cheers

pgtek
 
hi
Create formula
@Count

count({incidents.inc_rep_number},{offense.offense_code})
and insert it in your group section

cheers

pgtek
 
Or do a cross-tab by month (column) and by offense code (row)

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
thanks for the help...I'll try the suggestions.
 
I tried to do the suggested ideas, but it's not working. First I have to form the groups, (i.e. Robbery, Murder). Then I need to do a count for each group by particular dates. For example, Aug. 2001 and Aug. 2002 to compare months. Is there any simpilier way to achieve this?

I need it to look like this:
AUG. 2001 AUG. 2002
ROBBERY 23 56
MURDER 10 11

Thanks in advance for any help.
 
If you add a cross-tab you don't have to do any of those things. Did you try a cross-tab? What happened?

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
Ken is right, a crosstab should work. If limiting the dates to one month periods for each year is an issue, try creating a discrete number parameter called {?month} and then in your record select statement use:

{?month} = month({table.date})

Then in your crosstab, insert {table.date} as the column, and then select it and choose "group options" and choose "A column will be printed for each year." Also, at the bottom of the same screen, choose customize group name, using a formula:

monthname(month({table.date}))&" "&totext(year({table.date}),0,"")

(In my 8.0 this returns gobbledygook as a column heading until I refresh it, and then it appears correctly.)

Use offense as the row field, and then a count of the offense field as the summary field.

Place the crosstab in the report header or footer.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top