Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Sorting Data Post Reply Post New Topic
Author Message
thesmug1
Newbie
Newbie
Avatar

Joined: 12 Jun 2009
Online Status: Offline
Posts: 13
Quote thesmug1 Replybullet Topic: Sorting Data
     Posted: 29 Jul 2009 at 10:01am
I have some data that needs to be sorted.  Unfortunately the data are strings of digits rather than numbers.  For instance, if you tried sorting the following data by ascending, this is what would result.

12584443
258463

Obviously the first is larger than the latter.  So I used the following to convert the digits to numbers:

If NumericText({TLORDER.BILL_NUMBER}[1 to 2])
    Then ToNumber({TLORDER.BILL_NUMBER})

I used that code because some of the strings begin with letters rather than numbers.  The problem is that all the strings that begin with letters are changed to 0.  Does anyone know of an Else statement that would leave them unchanged?  I know that's probably a simple thing to do, but I am rusty...

Any help would be greatly appreciated.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Jul 2009 at 10:14am
In order to anser your question we would need to know how are you sorting the items that have an alpha inside the larger sort?
are they always going to be a the top or the bottom of your sort?
something else?
IP IP Logged
thesmug1
Newbie
Newbie
Avatar

Joined: 12 Jun 2009
Online Status: Offline
Posts: 13
Quote thesmug1 Replybullet Posted: 29 Jul 2009 at 11:12am
Sorry I forgot to mention that.  The letters will always be in the first or first and second positions in each string.  I would like to sort my list as such.  First I would like the lowest numeric values, followed by the strings starting with the lowest letters (A being the lowest, Z being the highest), followed by the strings that start with two letters.  I would like the strings that start with two letters to be sorted by the lowest first letter and then the lowest second letter.  All strings must be sorted by the lowest numerical values after the first one or two letters.  For instance, here would be an ideal list:

1082655
19344005
D125893
D145948
E183759
MP103382
MP329188
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Jul 2009 at 11:35am
I believe padding the left side with a zeros and then making it a set string length will achieve the sort as you desire.
You can adjust the number of zeros and/or total string length to make sense for your data set:
right('0000000000' + ({TLORDER.BILL_NUMBER},15)
Just sort on this formula field - you do not have to display it, just use it for sorting (or grouping)


Edited by DBlank - 30 Jul 2009 at 4:41am
IP IP Logged
Sampath Kumar
Newbie
Newbie
Avatar

Joined: 30 Jul 2009
Location: India
Online Status: Offline
Posts: 2
Quote Sampath Kumar Replybullet Posted: 30 Jul 2009 at 3:30am
Hi,

I have to sort ascending order for Pending amount this is a formula field?how we can make ascending order for formula fields.please guide me ? we are using CR2008
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jul 2009 at 4:43am
A formul field is used the exact same way as any other field when sorting.
However if your formula is using a function that is evaulated after sorting occurs then it will not show up as a field in the sort expert.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum