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!

"Sort by" Parameter

Status
Not open for further replies.
Aug 16, 2002
20
US
I have a report that shows total sales amount and volume for all of our products in a particular time period. I would like to prompt the user for what he wants to sort by, sales amount or sales volume. How do I link the parameter I create to the Sort order or, even better, the TopN feature?
FYI, both the sales volume and sales amount are group totals by Product.
 
To change the Sort or Top N, just create a formula which selects the field to sort by based on the parm:

If {?MyParm} = "Amount" then
{MyTable.Amount}
else
{MyTable.Sales}

Now use this field in the Report->Sort Records or the Top N.

-k kai@informeddatadecisions.com
 
I tried the if/then as well as a select/case formula, but I am still not able to choose my formula in the Sort Records or TopN Expert areas. The one difference in the above formula is that I do not want to sort by a field, but by a group total. Maybe this isn't possible. Can someone answer that?
 
Write the formula mentioned above using the fields, not the subtotals. Then do a subtotal of the formula. Then set the TopN based on that sum.

The tricky part is if you have different operations (ie sum vs count). Then you have to use 2 groups that appear like one, a technique that I call group cloaking). Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Solved! Thanks Ken for the final piece to the puzzle. You guys are great!

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top