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!

Dynamic sort order- tricky

Status
Not open for further replies.

KidFix

Programmer
Feb 7, 2002
60
US
Can anyone tell me if its possible to sort my report dynamically depending on a parameter passed in on viewing? It needs to be completely open ended (rather than just one of say three different sort orders) and may need to go to several layers (i.e. sort by this, then by this, then by this)

Any help would be much appreciated even if its just to say no it can't be done

Thanks in advance
Mark
 
I dont believe this is possible without using VB and the crystal report designer component. You would realistically have to write code to handle up to say 5 sort keys, or some sort of reasonable maximum. Even then, it would be a lot of work. Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
yes it is possible to affect the sort order depending on a parameter input..it can be done 2 ways

1. Affecting the report grouping

you would group on a formula such as this

If {?ParamInput} = "A" then
{Table.fieldA}
else If {?ParamInput} = "B" then
{Table.fieldB}
else
{Table.fieldC} //a catch all default

2. Placing a formula similar to the above in the Record Sort
Jim Broadbent
 
Both of those techniques are finite sorts, which also only allow for singular field sorting.

To make the sorts truly dynamic, I think you would have to resort to external code.

Naith
 
Dear Kid Fix:

How open ended? The tables in your report, do have a finite number of fields by which the data can be grouped that would make sense.

I would sit down and figure out what those finite number of fields are.

Then design the report with the maximum number of groupings your desire.

Lets say that you have a sales report.

You could group by Sales Date, Sales Year, Sales Person, Product, City, State, Region, Customer, Order#, etc!

So what I would do, is think about the Groups that would make sense for the report?

In other words you can take one report of a type and make it a Customer Order Report and then determine what types of variations in the sort make sense for a customer Order Report, maybe State, City, Customer, or Sales Rep, Customer, Product and so on until you have determined the various permutations. Same thing if it when it is run it is Sales Report; Sales Rep, Products, Customers etc.

Once you have done that, it will be easy but time consuming to set up the grouping. What I am trying to indicate is that you could have a parameter that says, What Report Type: Customer by Sales Rep, Customer by State by Product...

Then your formulas for the various groups would be easy to set up as you would know from the report type param, what they wanted to see the report grouped by.

Hope this was helpful....

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top