Solved

sorting crystal reports within a formula

Posted on 2013-01-17
2
1,048 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 101

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

628 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