Link to home
Start Free TrialLog in
Avatar of Bad_Fish
Bad_FishFlag for United States of America

asked on

Crystal Reports: Select Group Sort Field at Runtime

I have created a report that produces the "Top N" number of records based on a parameter field populated at runtime. I have two "summary" fields that I can select that will, in effect, control the group sort order; Sum of Quantity Ordered (this will sort the group by dollar amount) and Max of Item Number (this will sort the group by Item Number)...as shown below.

User generated image
The problem is that my user will sometimes want the group sort to be by Sum of Quantity Ordered and sometimes by Max of Item Number.

Rather than deploying the report in two versions, I'd like to allow the user to select which group sort order he wants "this time." My first though was to create a boolean parameter field to test if that selection was set to True or False and then, under Group Expert>Options>Use a Formula as Group Sort Order, create a formula that tests the value of the parameter field. Unfortunately, Crystal did not allow me to use a summary field in the formula. Only the below fields are available for use there.

User generated image
My question is; how can I allow my user to select, at runtime, the group sort order he needs?
Avatar of vasto
vasto
Flag of United States of America image

There are 2 options , unfortunately both require 3rd party software.
1st option is to use Millet software DataLink viewer. As far as I know it has an option to group on click.
2nd option is to use R-Tag Report Viewer, it will allow you to retrieve the report data and group it, pivot it etc. You can see how R-Tag will be used in this video:
http://www.r-tag.com/Pages/Preview_Dashboard.aspx

I know that there is a video showing DataLink viewer too , but I cannot provide you a link.
Avatar of Bad_Fish

ASKER

It's unfortunate that this is not a native option in CR...as I'm sure there's a lot of need for this ability. Thank you very much for the tips.

I'll leave this open for a bit and, if no one can provide a native answer by 6:00 PM, I'll close it out then.

Thanks again!
Avatar of Mike McCracken
Mike McCracken

Try this idea

Create 2 formulas

Cost Formula
If {?SortParameter} = "COST" then
    {Cost Field}
Else
     0

Units Sold
If {?SortParameter} = "SOLD" then
    {Sold Field}
Else
     0

Add summaries on both formulas as appropriate (SUM or MAX)
SOrt on both fields.
Only the one chosen will have values

mlmcc
That is, in essence, what I tried under Group Expert>Options>Use a Formula as Group Sort Order (I'm assuming that were you meant for me to try it). But, using your example field names...my code looked like this.

If {?SortOrder} = true then
    {Cost Field}
Else
    {Sold Field}

The problem is that neither {Cost Field} nor {Sold Field} are allowed to be used in that code block.  Only the fields listed in the red box of image 2 above are available to me in that area. No other fields, but those, can be used.

I think I'm out of options here but thanks again for the earlier tips.
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've requested that this question be closed as follows:

Accepted answer: 168 points for vasto's comment #a40467758
Assisted answer: 166 points for mlmcc's comment #a40467912
Assisted answer: 166 points for James0628's comment #a40468780

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.