Solved

Crystal Reports alphanumeric sort problem

Posted on 2011-03-19
4
1,009 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
[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
  • 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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql server connection string in config file 4 41
SQL 2008 - Disappearing Temp Table in Stored Procedure 24 62
Format Output of Select Statement 2 38
SQL Query 9 28
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 …
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

734 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