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

Sort by user parameter (Please help)

Status
Not open for further replies.

dreman

Programmer
Jan 16, 2002
272
US
Using CR 8.5:
The report is to analyze salesman region sales. the
Report is always grouped by salesman, but within salesman I would like to allow the user to sort by 1-area code or 2-zip code or 3-state
Also allow descending or Ascending order.
Any idea, please advise.
Thank you.
dré
 
Have a parameter that asks the user which they'd like to sort on.
Then create a formula along the lines of:
if {?sort} = 1 then {Report.Region} else
if {?sort} = 2 then {Report.ZIP} else
if {?sort} = 3 then {Report.Area}
Then sort on the formula.
I don't think you can offer them the option for sort area (without VB coding) - I'd love to be proved wrong though!
The downside of this approach is database performance - the sort will no longer be passed to the database.
If your DB supports CASE statements, you should be able to code this in a SQL function to speed things up. Andrew Baines
Chase International
 
Andrew is right on. I also would like to know how to do a conditional sort order. Is this feature coming in version 9? Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Yes this would work however I forgot to mention one critical obstacle, it is that the report is grouped by salesman and by customer ( to get customer $ YTD, $MTD..)
therefore, I need to be able to sort withing the group salesman and customer by 1-Area Code, 2-Zip code, 3-St is this possible in Crytal or Not ?

Report
Salesman: A....
Customer1A total: YTD, MTD, Area Code, Zip, St
Customer2A total: YTD, MTD, Area Code, Zip, St
Customer3A total: YTD, MTD, Area Code, Zip, St
Salesman: B....
Customer1B total: YTD, MTD, Area Code, Zip, St
Customer2B total: YTD, MTD, Area Code, Zip, St
Customer3B total: YTD, MTD, Area Code, Zip, St

Any hints, Please advise Thank you.


 
I was able to resolve it from the formula created above.
Need to manipulate the formula in this way:

the way to do is in the formula:

Local StringVar sort_by := {report.sls}+{report.cust_id};
// report will always be sorted by salesman + Customer Id+
// user choice (in our case 1,2 or 3)

if {?sort} = 1 then sort_by + {Report.Region} else
if {?sort} = 2 then sort_by + {Report.ZIP} else
if {?sort} = 3 then sort_by + {Report.Area}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top