Solved

Crystal Reports alphanumeric sort problem

Posted on 2011-03-19
4
968 Views
Last Modified: 2012-08-13
Hi all-

I use CR 2008 and have a field called itemCode which is a string and has values like R1, R10, R2, R44.002, R300, R9 etc. The "R" is always present and always at the beginning.
I need to sort them numericaly so that the result is R1, R2, R10 etc.  Currently it sorts like R1, R10, R2 etc.  
I need a formula to truncate the "R" and cast it to a number and then I can sort on the formula value.

Any help would be greatly appreciated.
Thanks
0
Comment
Question by:chamlight
  • 2
  • 2
4 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 250 total points
ID: 35172306
Try this idea

Create a formula
Val(Mid({itemCodeField},2)

Another way so you can keep the R

Left({itemCodeField},1) & CStr(Val(Mid({itemCodeField},2), "00000")

mlmcc

0
 

Author Comment

by:chamlight
ID: 35172430
mlmcc

Wow, that was fast.  Thanks, I'll try them.  BTW can you see any problems I might have with the following?


toNumber (replace ({chaProducts.itemCode},"R","",1,1,1))
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 35172465
That should work as well

mlmcc
0
 

Author Closing Comment

by:chamlight
ID: 35172477
Thanks.  Your solution is more...elegant
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

758 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

18 Experts available now in Live!

Get 1:1 Help Now