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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I count the occurances of a string in a report?

Status
Not open for further replies.
Jun 17, 2002
23
US
I am setting up a report which summarizes company activity for each calendar month. It includes a list of "samples" which were processed as well as the "department" in which they were done and the "price" for each sample. What I would like to do is total the number of times "department A" or "department B" appears in the list and total the "prices" for each department. I can probably handle the formulas if someone could point me to the correct commands to use.

Thanks
 
you haven't described your report structure very well.

I will assume that the structure is

Group 1 - Month
Group 2 - Sample Name
Group 3 - Department
Group 4 - Price

"What I would like to do is total the number of times "department A" or "department B" appears in the list and total the "prices" for each department."

the first part is no problem...though I am assuming you want the total by Sample Name.

Total prices for each department??? I don't understand what you want here..perhaps my grouping is wrong...clarify this

So far it doesn't sound like any formulas are needed.

Jim Broadbent
 
Sorry for the confusion, I'm new at this and i'm not REAL programmer in real life. The report looks like this:

Sample Department Price

sample 1 genetics $10.00
sample 2 pathology $20.00
sample 3 genetics $25.00
sample 4 pathology $23.00

I would like to count the number of "genetics" samples as well as the total cost of genetics samples. I usually have about 1200 samples in 8 different departments.

Thanks
 
You can do this with a Running Total or by creating the following formulas:

IF {Department}="Genetics" THEN 1 ELSE 0
A sum of this formula would give you the count.

and

IF {Department}="Genetics" THEN {Price} ELSE 0
A sum of this formula would give you the total cost.

A 3rd approach is to create a CrossTab...

Cheers,
- Ido CUT (Crystal UTilities): e-mailing, exporting, electronic bursting & distribution of Crystal Reports:
 
If you want a report that looks like this:

Sample Department Price
sample 1 genetics $10.00
sample 3 genetics $25.00
Subtotal genetics $35.00

sample 2 pathology $20.00
sample 4 pathology $23.00
Subtotal pathology $43.00


Then insert a summary by Department, one to count the records and one to sum the price.

Software Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
One of the problems here is that the actual department name is not available in the database that I am reporting from. It is "calculated" using other pieces of information and therefore is not available except to second pass formulas which can not be used to create running total fields.....I think.
 
Post your formula for Department and we can tell you if that is the problem or not. Software Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top