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

Sort order (ascending vs. descending) based on variable?

Status
Not open for further replies.

ddegraff

IS-IT--Management
Apr 22, 2009
1
US
I'm sure this has been asked before but I searched existing threads with no luck.

The goal is to use to use one Crystal template to allow users to get multiple views of sales results for retailers based on a number of timeframes, by refreshing the report with parameter values to define a) what variable to sort on and b) in what order. I think I've got "a" covered, but haven't seen a way to control Ascending vs. Descending?

Appreciate any advice/examples. Thanks!!
 
For numerics or numeric codes, you could do it by subtracting it from a very large value.

Or you could have two nested groups. The code value is shown as ascending for one and descending for the other. A parameter would choose ascending or descending. When it was descedning, the field used for ascending would contain a single value and only descending sort would count.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
For numeric sorting ascending versus descending just multiply by 1 or -1 as the case calls for.

Software Sales, Training, Implementation and Support for Macola, Synergy, and Crystal Reports. Check out our Macola tools:
 
Create separate options for your parameter picklist:

"Store, Ascending"
"Store, Descending"
"Date, Ascending" //etc.

Then create two separate formulas like this:

//{@sortbyascending}:
select {?Sort}
case "Store, Ascending" : {table.store}
case "Date, Ascending" : totext({table.date},"yyyy-MM-dd")
case "Amount, Ascending" : totext({table.amt},"00000000.00")
default : ""

//{@sortbydescending}:
select {?Sort}
case "Store, Descending" : {table.store}
case "Date, Descending" : totext({table.date},"yyyy-MM-dd")
case "Amount, Descending" : totext({table.amt},"00000000.00")
default : ""

Place both in the record sort area and check 'ascending' for one 'descending' for the other.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top