Sorting with parameter fields of type date, number and string

Posted on 2008-09-30
Last Modified: 2012-05-05
hi, i have added a parameter to my report so i can choose what to sort by.
I have managed to sort it by creating a formula with a switch function to change according to the parameter the fields its supposed to sort by. the only problem is i need to sort it by different field types.
How can i do this?
i managed sorting by date and number types, i convert the date field to numbers without "/" and it sorts perfectly. however the string (table.Name) cant be converted to number. If i convert all to String type, the numbers as string will not sort properly (for ex. 100.1 will go before 15)
what can i do so i can sort with all types?
Question by:carlosmonte
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
  • 2
LVL 101

Accepted Solution

mlmcc earned 400 total points
ID: 22611026
Try this idea to convert the numbers


That should put 0's on the front of the string

Another idea is

Right("0000000000" &CStr({YourField},4,''),15)


Author Comment

ID: 22614001
sorry, but i dont know how this would help me.
can you explain? will this way make sorting possible for all db fields like Date, numbers and strings?
LVL 101

Expert Comment

ID: 22614313
If you convert numbers into strings of the same length and add leading 0's then then sort correctly.

Your example of 100.1 and 15  becomes

Thus it sorts correctly.  You simply use them for the sorting and use the real field for display.



Author Comment

ID: 22614847
works great, nice little trick.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
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 will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Suggested Courses

627 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