Solved

Classifying a group and then count based on the classification

Posted on 2012-03-23
20
407 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
ID: 37757216
Set the runninig total to evaluate on change of group

mlmcc
0
 

Author Comment

by:josslmpd
ID: 37757762
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
ID: 37757809
What field is the type?

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

mlmcc
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:josslmpd
ID: 37757865
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
ID: 37757894
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
ID: 37757924
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
ID: 37758049
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
ID: 37758267
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
ID: 37758285
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
ID: 37758290
What is the group?

For the above data you need 3?

Can you upload the report?
No data needed

mlmcc
0
 

Author Comment

by:josslmpd
ID: 37758356
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
ID: 37758421
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
ID: 37758496
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
ID: 37758748
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
ID: 37758967
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
ID: 37759055
Attached the wrong one apparently

mlmcc
incidentbyoffense-1-.rpt
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37759069
Still wrong

mlmcc
incidentbyoffense-rev1.rpt
0
 

Author Comment

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

Accepted Solution

by:
mlmcc earned 500 total points
ID: 37759258
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
ID: 37759266
thanks for all of the follow up!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Crystal Reports - Trim Data 7 64
"A string is required here" error in Formula 7 57
Crystal image Object type? 7 37
How to modify the SQL query in Crystal 2016 1 28
Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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