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

Urgent help with Actually changing a group depending on Parameter sele

Status
Not open for further replies.

MrHelpMe

Technical User
May 1, 2001
203
CA
Hello,

I am using crystal reports 9 and cannot figure out the best way to handle this problem. I am connecting to a stored procedure and current I have 2 groups in the report. 1 called worktype(ie. Enhancement) and the secon group called Business Unit(ie. Communications). Basically the report currently looks like this
Enhancement
Communications
Project-74-EventMgmtPlanning Oct282003 500 $10,000.00
Project-75-Portal Nov302003 400 $20,000.00

Now depending on the sort type the user chooses ie. 0=BusinessUnit and 1=WorkType the report will need to change it's grouping. So basically in the above example Sortype was equal to 1.
Now the problem is if the user chooses Sorttype 0(BusinessUnit) I need the report to look as follows.
Communications
Enhancement
Project-74-EventMgmtPlanning Oc282003 500 $10,000.00
Project-75-Portal Nov302003 400 20,000.00

Without affecting the totals, subtotals and grand totals.

 
Check out the following Crystal Decisions Knowledge Base article:


I've used this method before many times. Basically you create a formula field based upon your possible parameter values selections. Then create a group based on the formula instead of a specific database field.
 
Hi,
Create formulas for the Group instead of using actual field names, then use a passed parameter to determine
what field to group on..
I found code in this forum to do that, but, since I can't remember where, here are some examples from a report I built based on that code:
The user may choose 1 of 2 values for Group1 and Group2
and, based on which choice is made, the following formulas determine the actual group name:

{@GR1Choice}
Code:
if ({?Gr1Pick} = 'O'  and {?Gr2Pick} <> 'O' ) then 
{HR_PUBLIC.OFFICE_NM}
else
If ({?Gr1Pick} = 'J' and {?Gr2Pick} <> 'J' ) then
{HR_PUBLIC.JOB_DESC}
The above sets the First group then
{@GR2Choice}
Code:
if ({?Gr1Pick} <> 'O'  and {?Gr2Pick} = 'O' ) then 
{HR_PUBLIC.OFFICE_NM}
else
If ({?Gr1Pick} <> 'J' and {?Gr2Pick} = 'J' ) then
{HR_PUBLIC.JOB_DESC}
Determines Group 2


The code allows for no choice, in which case no grouping is done and it checks for inconsistant choices ( both groups the same)in which case no grouping is done as well.

hth,
[profile]

 
So then - Sorttype - is a user entered parameter

you create 2 formulas....

//@Grouping1 (used for Group 1)

if {?SortType} = 0 then
{Table.BusinessUnit}
else
{Table.WorkType}; //doing it this way makes this the
//default if the user enters bad data

//@Grouping2 (used for Group 2)

if {?SortType} = 0 then
{Table.WorkType}
else
{Table.BusinessUnit}; //doing it this way makes this the
//default if the user enters bad data

Now just group on these formulas

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
This site rocks guys.

Thank you everyone. I wasn't thinking correctly. All of your answers were extremely helpful. I plugged in the above formulas and everything worked successfully. Thanks for your quick replies.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top