Print Page | Close Window

Tip: How to do flexible grouping

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Tips and Tricks
Forum Discription: Have you learned some great tricks to share with the group? Post them here!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=16317
Printed Date: 03 May 2025 at 4:34pm


Topic: Tip: How to do flexible grouping
Posted By: dbodell
Subject: Tip: How to do flexible grouping
Date Posted: 30 Apr 2012 at 5:45am
One of the most useful things that I do when developing summary reports is to allow the user to select how they want the data summarized when they run the report. So, for example, I provide them a parameter for Group1, a parameter for Group2 and a parameter for Group3. In Group1 they have certain predefined choices (in my world they are things like Location, Department, Physician, Insurance) or "None" in case they don't want to use that summary level. I provide similar options for groups 2 and 3. In this manner the user can choose to run the report one time by Location, then Department and then Physician. Next time they can run it by Department / Physician / Insurance. The one report allows them complete flexibility in how to summarize.
 
It is relatively easy to set this up. First of all, as I outlined above, you will create multiple group level parameters: Group1, Group2 and Group3 for my purposes. These will be string parameters that are static. I will enter in the list of possible choices that you want them to have in the value list, putting "None" as the first value. For my example, I would enter values like "Loc","Dept", "Phys", etc. In the description field for the value I would enter "Visit Location", "Visit Department" and "Visit Doctor".
 
Once I've done this for all three Group parameters, I need to set up 3 formulas: one for each group. I will use these formula fields to actually group my data. My formula for Group1 would be something like:
 
if {?Group1} = "None" then "No Grouping" else
if {?Group1} = "Loc" then {MyTable.LocID} + {MyTable.LocationName} else
if {?Group1} = "Dept" then {MyTable.DeptID} + {MyTable.DeptName} else
if {?Group1} = "Phys" then {MyTable.PhysID} + {MyTable.PhysicianName} else
"No Grouping"
 
After I have a formula field set up for each possible grouping, I set my report groupings to be Group1/Group2/Group3 in that order.
Finally I set the group headers and footers to be suppressed if the value for that level of grouping is "None". This is usually only necessary on Group3 but I do it for Group2 as well.
 
Have fun! If you have any questions don't hesitate to ask.


-------------
Thanks,
D. Bodell



Replies:
Posted By: varunseo143
Date Posted: 07 May 2012 at 7:37pm
We would like to do flexible grouping as a grade level for math. There are 5 teachers. There is some dispute about the best way to do this. Has anyone tried it wioth 5, have ideas, or research to back up the idea?
We really don't want to try to teach 100 different kids or the kids to have 5 different teachers.
Thanks.


-------------


Posted By: dbodell
Date Posted: 08 May 2012 at 2:49am
Hi. I guess I don't really understand what you mean by having 5 levels and 5 teachers. The principles for flexible grouping would be the same for 5 levels as it would be for 3 levels. In my example I could have grouped by
 
Location \ Physician \ Insurance
 
with Location being the top level of summary, Physician being the second level of summary (within location) and Insurance being the third level (within physicial within location).  What kinds of groupings do you want to have on your report and what would the choices be? What does having 5 teachers have to do with grouping the report or teaching how to do the report?


-------------
Thanks,
D. Bodell



Print Page | Close Window