sorting crystal reports within a formula

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

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

Who is Participating?
mlmccConnect With a Mentor Commented:
2 ideas

1st method
 Create 2 formulas
First formula
If {?SortOrder} = "U" Then

Second formula
If {?SortOrder} <> "U" Then

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

mgmhicksAuthor Commented:
Used method 2 worked great.  Thank you!!
All Courses

From novice to tech pro — start learning today.