From your example, I am not sure that you are talking about sorting or grouping, because you are saying "grouping" but your example data shows "sorting".
I also don't know how you are planning to get the results of the user's selection of the desired sort from the radio button into the report. I will assume that you will use a crystal report parameter, and pass the user's sort preference into the report via a parameter from the VB/C# environment or by having the Crystal Report prompt for this parameter value at runtime.
In either case, I think you can get what you are looking for by adding a string formula field that yields the color, clarity, or carat of the detail record using an "if" statement:
if {?opt} = 0 then {TABLE_NAME.Color}
else
if {?opt} = 1 then {TABLE_NAME.Clarity}
else
if {?opt} = 2 then ToText({TABLE_NAME.Carat},"###.00")
else
"?"
Then, you can sort or group by this new field.
The masking on the Carat field is necessary so that a value of 10 will come after a value if 2.0. With a field like Carat, maybe you won't see this issue (because > 9 Carats may not occur in your data), but I think you can see the issue - also make sure you have enough #'s, or else 1000 will appear before 200. If you don't want to guess, you can implement 2 formula fields, one a string and the other a decimal value, and use both to create the groups or sort sequence.
Also - when creating formulas, pay attention to EvaluationTime - I generally use WhilePrintingRecords for all of my formulas, but I do not believe you will need that in this one.
Edited by wjzabs - 17 Mar 2009 at 5:17am