there is no problem doing this with a little thought
AS SV has pointed out you use 3 grouping formulas - one for each group.
The results of all of the formula if-then formulas
MUST have the same datatype for this to work....generally speaking that is a String type
As far as the parameters involved you can adopt 1 of 2 approaches
1. Give the user combinations of groupings to choose from with no option to choose their own
eg.
?Report Grouping
Parameter type : String
Description : Select one of the following report groupings
1 - city region month
2 - city month region
3 - month city region
4 - region city month
Default setting: 1
The advantage to this method is the ease of programming since the parameter is predictable.
The disavantage is that the user will want another combination and even with 3 values there are 6 combinations and there is limited space in the description to give all possibilities
2. Give the user 3 parameters to enter...?ReportGroup1, ?ReportGroup2, ?ReportGroup3,
Set as the default the most common grouping...ie:
?ReportGroup1 - Region
?ReportGroup1 - City
?ReportGroup1 - Month
But let them choose the values themselves
Advantage : No complaints about not being to get their favourite view of the data.
Disadvantage: must take care to deal with bad user input
I prefer method 2 myself since I hate revisiting a report to create another case
Method 2 formulas
the trick here is to a) have the grouping values as strings
b) assign a default and handle bad input
the first group is straight forward
@Group1
if {?ReportGroup1} = "City" then
{Table.City} //assuming it is a string
else if {?ReportGroup1} = "Month" then
totext({Table.Month},"MM"
else
{Table.Region}; //this is the default value and catch-all for bad input
@Group2
if {?ReportGroup2} = "Region" and
{?ReportGroup1} <> "Region" then
{Table.Region}
else if {?ReportGroup2} = "Month" and
{?ReportGroup2}<> "Month" then
totext({Table.Month},"MM"
else
{Table.City}; //this is the default value and catch-all for bad input
@Group3
if {?ReportGroup3} = "Region" and
({?ReportGroup1} <> "Region" or
{?ReportGroup2} <> "Region" ) then
{Table.Region}
else if {?ReportGroup3} = "City" and
({?ReportGroup1} <> "City" or
{?ReportGroup2} <> "City" ) then
{Table.City}
else
totext({Table.Month},"MM"

; //this is the default value and catch-all for bad input
NOW THE FINAL THING I DO
Is create a formula called
@ReportSorting
WhilePrintingRecords;
"Report sorted by : " + {?ReportGroup1} + "/" + {?ReportGroup2} + "/" + {?ReportGroup3);
I put this formula in the report header somewhere so that the user can see why his report did not function the way he thought it would (ie...he typed improper input)....trust me ...it saves a lot of headache later on if you do this.
Hope this helps you
Jim Broadbent