cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically change the sorting or ORDERBY in crystal

Former Member
0 Kudos

<p>How can i change the sort fields depending on a value of a paramete?</p><p>Like i have a Bool parameter and want to twiest the sort fields of the subreport depending on the parameter value.</p><p>My purpose will serve if i can change a group depending on the parameter.</p><p>looking for help out there.</p><p>-Pathik</p>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

In the Change Group Options dialog, there is a check box that called "Use Formula as Group Sort Order". When toggled on, click on the conditional formula button.

Put in the formula for your evaluation as you wish. For example:

If {?MyParameter} then crAscendingOrder else crDescendingOrder

Don't forget that there is the option for crOriginalOrder if you so choose.

- Kathryn Webster (Report Design Consultant)

Former Member
0 Kudos

Thanks Kathryn,

i couldn't find the "Use Formula as Group Sort Order" in CR10. But i understand what you said. i did it by using the written formula (which is actually giving two different DB fields for sorting) as a group. is that what you mean?

I can use that same formula in Sort Expert to sort instead of using it as a group if the data is on the detail section only.

Thanks again.

-Pathik

Notes : The company i am working with named "Webstercare".

Former Member
0 Kudos

Hi Pathik.

You are right on. Your solution is what I would have done too if I didn't have this cool new feature. I guess it was added even more recently than I remember. 🙂

Too funny about the company name that you work for. I'm just new to this name myself. Still getting used to it. I hope it's a good company (like the family is to me). ;-)Â

    - Kathryn Webster (Report Design Consultant)
          Kat&#39;s News: http://diamond.businessobjects.com/blog/279


Former Member
0 Kudos

<p>Hi,</p><p> Im new to Crystal Reports.</p><p>Im Using Crystal Report XI .</p><p>I want to sort the report by clicking the column_header at runtime.</p><p>How to implement this ?</p><p>&nbsp;</p><p>Please Help me as early as possible. </p>

Former Member
0 Kudos

Have you asked this question in the development forum? In the section that applies to your development environment of choice?Â

    - Kathryn Webster (Report Design Consultant)
          Kat&#39;s News: http://diamond.businessobjects.com/blog/279


Former Member
0 Kudos

hi,

Yaa, I've asked this Question in Development forum also.

But, How to Design the Report for Runtime Sorting?

Please give me reply

Its very very important to me.

Venkat.S

Former Member
0 Kudos

 I'm sure you've seen by now I want to help everyone. Unfortunately, Runtime stuff is purely SDK driven. Please persist with the developer forum. They are the right guys for the job.

Kind regards,

   - Kathryn Webster (Report Design Consultant)
          Kat&#39;s News: http://diamond.businessobjects.com/blog/279


Answers (3)

Answers (3)

Former Member
0 Kudos

In order to do this, you need to set up a parameter with limited default values. Then you create a formula based on the allowed default values for the parameter. You then use the formula as either your grouping or sort option. For example, there is a sales report that you would want to sort by either salesperson or region:

Your parameter would prompt for either salesperson or region. Your formula would look something like this:

 If ?Parameter = "Salesperson" then SalesTable.Salesperson else SalesTable.Region

 You would then use this formula as either your grouping or sorting criteria.

 Hope this helps.

Former Member
0 Kudos

It depends on what you want to do as to how you develop and design. If you are wanting to just change sort order, you will have to set the sort order conditional formula to something like crascendingorder. Look up these types of words in the help system.

Also, another level of complexity, of perhaps changing the field being sorted, you could use a Formula to change the field being displayed (and then use the above mentioned sort order conditional formula on top of that).Â

   - Kathryn Webster (Report Design Consultant)
          Kat&#39;s News: http://diamond.businessobjects.com/blog/279


Former Member
0 Kudos

Create a Parameter with your choices. Create a formula with your sort parameters: like @Sort

 

If {?SortField} = "Item" Then ({CHG_Change.Item}; crascendingOrder ;)<br />Â Â Â Â Â Else ({@Date }; crdescendingOrder;)

 

Move your formula into a header and then suppress. click on your sort icon and move @sort to the sort process.

 

I was able to get that to work.

 

However, what I cannot find is how to sort on more than one field.. I am unable to locate a statement that executes properly, only error free.

 

*Robert *

Former Member
0 Kudos

<p>&nbsp;</p><p>How can i change the sort fields depending on a value of a parameter?</p> <p>Like i have a column_name as a parameter and want to sort the fields of the report wrt to the column_name dynamically .</p><p>please help me.............. </p><p>&nbsp;</p><p>- Venkat.S <br /></p>