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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text field formula help

Status
Not open for further replies.

smmt2207

MIS
Feb 27, 2007
36
US
I have a field that is alphanumeric. The majority of the fields are numbers. When I sort they do not sort in numerical order. I would like to add a leading zero to any field that is 3 characters so they will sort correctly. See below example

Current sort
100
101
102
20
201
202
203

Would like to see
020
100
101
102
202
202
203

Thank you in advance

Margie
 
Try using a formula like this:

Code:
If IsNumeric({table.field}) then
  If len({table.field}) < 3 then 
    right('00' + {table.field}, 3)
  else {table.field}
else {table.field}

-Dell


Associate Director, Data & Analytics
Protiviti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top