Solved

Classifying a group and then count based on the classification

Posted on 2012-03-23
20
404 Views
Last Modified: 2012-06-27
I have a report in which I used the details section to classify my group.  I classified the group based on some selection and sorting formulas.  I now want to know how many of each type of group that I have based on the classification that I determined.  I tried using three running formulas that evaluated only a certain value, but the running total counts the information in the details section so I end up with inflated numbers.

My data is set up like so:

Group Name     Group Classification based on detail
detail
detail
detail

So it looks like this with data

case_ID          Type A
A
B
B

Case_ID 2       Type B
B
C

Case_ID3      Type C
C

So my goal would be to have a total that tells me that I have one of each type of group.  My running totals though are giving me a total of 1 for group A, 1 for group C, but 3 for group B.

Can I do what I want to do here?  This has plagued me for sometime and I am at a complete mental block so I am open to any suggestions.  I just need to get rid of my inflated numbers and make sure that each case_id (i.e. each group) is only counted once.  The difference is about 200 records and it is really messing up my statistics.

Also I have an intermediate level of crystal experience so very explicit instructions in any suggestions would be most appreciated.
0
Comment
Question by:josslmpd
  • 10
  • 9
20 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Set the runninig total to evaluate on change of group

mlmcc
0
 

Author Comment

by:josslmpd
Comment Utility
If I evaluate on change of group it just counts the groups and gives me a total count.  I do not get a breakdown by type.
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
What field is the type?

I thought the CASEID was the group and the TYPE was what you wanted to count.

mlmcc
0
 

Author Comment

by:josslmpd
Comment Utility
The type field is a formula that is displayed in the group header.  I do want to count TYPE.  IF I evaluate based on group is gives me a total count of the number of groups.  If I reset the count based on TYPE or group I don't get the correct information either.
0
 
LVL 19

Expert Comment

by:GJParker
Comment Utility
I'm not following your description of the issue here,

how are you using the details to classify you groups ?
what groups do you have ?
what are you trying to count ?

It would be simpler to follow if you provided an example of the data and structure and what the expected outcome is
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Is the type the same for the entire group?
or is the type shown the type of the first record?

Have you tried a distinct count of the type formula?

mlmcc
0
 

Author Comment

by:josslmpd
Comment Utility
Sorry for the poor description.  I am looking at crime data.  An incident may have multiple offenses associated with it, but I only want to count each incident once.  I also need to count it for the most serious crime.  All of the offenses for an incident are listed in the details.  I have a formula that classifys the individual offenses into a category (Homicide, Sex Crime, Assault, Other) and then a custom sort order that lists the offenses in order based on servity of crime.  The category formula is placed in the group header so that it only displays the most severe crime.

Incident 1     Homicide
Homicide
Assault

Incident 2    Rape
Rape
Burglary

Incident 3   Assault
Assault
Kidnapping
 
The running totals still counts the detail information, though, so it looks like six incidents occurred when there were really just 3.  I think my flaw is that the displayed information is not a "real field" it is really just displaying the first of the two records.  So it works for display but not for statistics.  I don't know how to make that field "real" enough for summary information.  I can always export the report to excel and do a count, but I was hoping to do it all in a single report with crystal and or SQL.

Hopefully this description is a little clearer and not worse.
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
How do you have the running total setup.

It would seem you want to count/evaluate when the INCIDENT field/group changes

mlmcc
0
 

Author Comment

by:josslmpd
Comment Utility
The INCIDENT field changes everytime though.  As I said, counting on that group just gives me a total count of incidents.
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
What is the group?

For the above data you need 3?

Can you upload the report?
No data needed

mlmcc
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:josslmpd
Comment Utility
The group is the incident ID.  If the formula was working correctly, for the above data I would have three total incidents, one of each type.
incidentbyoffense.rpt
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Try this one.  It evaluates on the change of the group.

Are you trying to get the number of each "subtype" also.  SO what you want is

Incidents - 3
Assault - 1
Homicide - 1
Sex Crime - 1
Burglary - 0
Kidnapping - 0

The ones with 0 may not show.

mlmcc
incidentbyoffense-1-.rpt
0
 

Author Comment

by:josslmpd
Comment Utility
What you typed is what I want.  The proposed solution in the attached file doesn't give me that though.  I cannot evaluate based on change of group.  It gives me the total number of incidents, without out any breakdown.
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
That is a different issue than the problem we were trying to solve.  It can't be solved with summaries or running totals since they cannot be controlled

See if this is what you want.

This method will work for small numbers of offense types.  If you need more offense types and they might vary then another method will be needed.

mlmcc
incidentbyoffense-1-.rpt
0
 

Author Comment

by:josslmpd
Comment Utility
I must not have been clear in my original post.  My only issue from the very begining was to get the sub-types totals nothing else.  I didn't think that it could be solved with summaries or running totals, but I wanted to double check.  This report looks the same as the last one, how is it different?
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Attached the wrong one apparently

mlmcc
incidentbyoffense-1-.rpt
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Still wrong

mlmcc
incidentbyoffense-rev1.rpt
0
 

Author Comment

by:josslmpd
Comment Utility
Yes!  Thank you.  Could you in general explain what you did?
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
Comment Utility
I added 3 formulas to the group header to count the types

WhilePrintingRecords;
Global NumberVar AssaultCount;
If {@Offense Code} = "Assault" then
    AssaultCount := AssaultCount + 1;
""

I then have display formulas
WhilePrintingRecords;
Global NumberVar AssaultCount;
"Assaults : " & CStr(AssaultCount,0)

There is also a DeclareCounters formula that should be in hte report header
WhilePrintingRecords;
Global NumberVar SexAssaultCount;
Global NumberVar AssaultCount;
Global NumberVar HomicideCount;
""

mlmcc
mlmcc
0
 

Author Closing Comment

by:josslmpd
Comment Utility
thanks for all of the follow up!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now