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

best way to group or show report 1

Status
Not open for further replies.

rhartigan

Technical User
Apr 1, 2011
6
0
0
US
I'm working on a report to show or group inmates. Each inmate has charges which are either misdemeanor or felonies. Most inmates have both and a few are either one or the other. Right now it looks kind of like this.

inmate 0001a (Grouped by Inmate Number)
Charge 1 Misdemeanor
Charge 2 Felony
Charge 3 Misdemeanor

inmate 0001b
Charge 1 Misdemeanor
Charge 2 Misdemeanor

inmate 0001c
Charge 1 Felony
Charge 2 Felony
Charge 3 Felony

I've been asked to show the group or show the data by those inmates who only have misdemeanors, those who only have felonies, and those who have a combination. Any help would be appreciated. Thanks in advance.
 
You can handle this using group sorts. First right click on the chargetype field, and insert a distinctcount at the inmate group level. Then also insert a maximum on the chargetype field at the inmate group level. These are necessary to activate the group sort, but you can remove them AFTER using the group sort.

Next, go to report->group sort->inmate group->select"All"-> "distinctcount of chargetype", descending. Then select "maximum of chargetype" as your second sort, ascending order. This will organize clusters of both types, followed by felonies and misdemeanors. To create faux group headers corresponding to these three clusters, insert a second group header on the inmate group and move the groupname to GH_b. Then add a formula to GH_a:

//{@header}:
whileprintingrecords;
stringvar hdr;
stringvar prev;
prev := hdr;
if distinctcount({table.chargetype},{table.inmateno}) = 2 then
hdr := "Both Felony and Misdemeanor" else
if distinctcount({table.chargetype},{table.inmateno}) = 1 then
hdr := {table.chargetype};
;
if prev = hdr then
"" else
hdr

Then go into the section expert->GH_a->suppress->x+2 and enter:

{@header} = ""

-LB
 
Thank you so much!!! Grouping is definitely one of my weakest areas of crystal.

Just one more question if you don't mind, how would I count the number of inmates under each charge type grouping. I've tried running totals but can't seem to get it.

Thanks again!
rhartigan
 
Where do you want to see these totals? Is the report footer okay?

-LB
 
Anywhere, including the Report Footer is fine, I just need to see the totals. Sorry for not mentioning it sooner. Some of this I had hoped to figure out for myself.

Thanks!
 
Then you can just add running totals that do a distinctcount of the Inmate, evaluate using a formula, reset never. Use an evaluation formula like the following in the appropriately named running total:

//for the #Felony rt:
distinctcount({table.chargetype},{table.inmateno}) = 1 and
{table.chargetype} = "Felony"

//for the #Misdemeanor rt:
distinctcount({table.chargetype},{table.inmateno}) = 1 and
{table.chargetype} = "Misdemeanor"

//for the #Both rt:
distinctcount({table.chargetype},{table.inmateno}) = 2

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top