Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Question Crystal 8.5 Sorting Numbers

Status
Not open for further replies.
May 25, 2003
24
AU
When I tried to sort a column I'm getting the below sort, I would like to sort the column so Crystal reads 1-10 the 11 -20, 21-30
Thanks

1
1
1
1
11
12
13
14
15
2
21
22
23
etc
 
That means your "number" field is really a string. You can create a formula that converts the string to a number, then sort on the formula. Something like this:
[tt]
//@Sort
Val({Table.YourField})
[/tt]
-dave
 
Another approach would be to use a SQL Expression, which will offload the process to the database.

If you need to retain the field as a string for some reason, create a formula (Use Insert->Field Object->Right Click Formulas):

picture({table.field},"00000000")

This will pad it with zeros.

Otherwise use Dave's formula.

-k
 
Hi Dave,

What is the step to do the conversion from string to number?

Thanks
 
The fomula in my previous post will handle the "conversion" from string to number (that's what the Val() function attempts to do). Here's a complete walkthrough:

Create a formula field named "Sort" using the formula in my previous post (click the Insert menu > Field Object > highlight Formula Fields > CTRL+N > type Sort for name > and enter the formula I posted).

Then, click the Report menu > Sort Records > highlight your new formula (@Sort) > and click the Add button.

That should do it...

-dave
 
does this look correct?

//@SortVal({1__PRFs__M__Days_Idle__TBC_._12})
 
What you posted is a comment of a formula which doesn't appear to be correct.

To get the value of a string, select from the menu Insert->Field Object->Right click the Formulas and select New->Name it and then type:

val({table.field})

Now select Report->Sort Records and point to the formula that you created.

-k
 
Got it to work, Thanks alot for your help,
I was doing this

//@SortVal({Table.YourField})

instead of what's below

//@Sort
Val({Table.YourField})

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top