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

Optional sorting

Status
Not open for further replies.

penkehenke

Programmer
Jun 21, 2004
15
SE
Hi out there in the cyberspace!

I have problems with sorting.
Is there any way to have optional sorting in a report based on parameters?

The resulting sql should be order by col1
or order by col2 depending on my parameter.

I cannot figure out how to do that....

I would be jumping up and down in joy if anyone has a solution to this problem.

/Henrik
 
I've written Crystal 8.5 reports that used a parameter to select which field should be used for sorting. This works fine, so long as you are not using groups.

Madawc Williams (East Anglia)
 
How do you make the parameter affect the order by?
Sorry, but I'm new to this Crystal thing and I get confused most of the time while I'm trying to understand how it works.

(I'm using version 10, forgot to put that in my first post...)
 
You set up a formual field. This checks the parameter value and chooses a database value. You then use this for sorting. You can even mix text and numeric, using the ToText command.

Madawc Williams (East Anglia)
 
Just to clarify the solution form Madawc

Create a formula in the report using a parameter to decide which field to display i.e.

//@SortField

If {?SortParam} = "Q" Then
{Table.SalesQty}
Else if {?SortParm} = "V" Then
{Table.SalesValue}
Else
{Table.SalesMargin}

Then set this field as the field to sort on in your report.

This will give the result of sorting by Quantity or Value depending on the parameter entered by the user and will sort by margin as the default.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Thank you!!!
Now I'm jumping up and down :)

Seriously, you've been very helpful.

Enjoy life and may the source be with you!
 
Glad I could Help

Who said Friday the 13th was unlucky

Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top