Solved

Sorting with parameter fields of type date, number and string

Posted on 2008-09-30
4
466 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

11 Experts available now in Live!

Get 1:1 Help Now