Solved

Sorting with parameter fields of type date, number and string

Posted on 2008-09-30
4
468 Views
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?
thanks
0
Comment
Question by:carlosmonte
  • 2
  • 2
4 Comments
 
LVL 100

Accepted Solution

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

CSTR({YourField},"0000000000.00000")

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

Another idea is

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

mlmcc
0
 
LVL 1

Author Comment

by:carlosmonte
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?
0
 
LVL 100

Expert Comment

by:mlmcc
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
000000015.00000
000000100.10000

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

mmlcc

0
 
LVL 1

Author Comment

by:carlosmonte
ID: 22614847
works great, nice little trick.
Thanks
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

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 …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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