Solved

sorting crystal reports within a formula

Posted on 2013-01-17
2
879 Views
Last Modified: 2013-01-17
I have the following formula that allows to select to field on want to sort on.  That seems to work, however I cant override the default sort.  If its by date then I want descending and ifs by unitid I want ascending order.  Here is the formula that doesnt work when I try and add the sort direction.

If {?SortOrder} = "U" Then
 {TAG_InsuranceReport2;1.UnitId}
Else
  toText({TAG_InsuranceReport2;1.EndDate},"yyyy-MM-dd")

I have tried adding crAscendingOrder at the end of lines then the formula errors out and says its not part of the formula.

thanks
0
Comment
Question by:mgmhicks
2 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 38790236
2 ideas

1st method
 Create 2 formulas
First formula
If {?SortOrder} = "U" Then
 {TAG_InsuranceReport2;1.UnitId}
Else
    "A"

Second formula
If {?SortOrder} <> "U" Then
 {TAG_InsuranceReport2;1.EndDate}
Else
   Date(1900,1,1)

Put the formulas in as the sort fields
Set the first to Ascending and the second to descending

2nd method
Use your existing formula a a group not a sort.  Groups are the first sorts done so the sorting will take place.
You can suppress the group header and footer.
When you add the group you can set the sort order.  Click the formula button to the right of use a formula to determine sort order
If {?SortOrder} = "U" Then
   crAscending
Else
   crDescending

mlmcc
0
 

Author Closing Comment

by:mgmhicks
ID: 38790481
Used method 2 worked great.  Thank you!!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now