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

Grouping data by the 'last three characters'

Status
Not open for further replies.

pokerace

Technical User
May 24, 2005
118
US
I would like to sort info in a report by the last three characters in a field. For example, say that I pull the following data (just a lot more of it):
ABC123
XYZ123
ASDF333
ZZGG333
JJJAA444

The last three characters indicate location, so I would like to sort/group this data by the last three characters. Since the data length isnt't constant I can't use mid in the formula.
 
Actually, I was able to do this with the mid in the following formula. Might not be the best way but it worked:

mid({VOC_TRAIN_CLASS_LKP.VOC_TRAIN_CLASS_DSC},Length ({VOC_TRAIN_CLASS_LKP.VOC_TRAIN_CLASS_DSC}) - 2,3)
 
The Right function would work as well:

right({VOC_TRAIN_CLASS_LKP.VOC_TRAIN_CLASS_DSC},3)

~Brian
 
to be safe:

if not(isnull({VOC_TRAIN_CLASS_LKP.VOC_TRAIN_CLASS_DSC}))
and
len(trim({VOC_TRAIN_CLASS_LKP.VOC_TRAIN_CLASS_DSC})) > 2 then
right(trim({VOC_TRAIN_CLASS_LKP.VOC_TRAIN_CLASS_DSC}),3)
else
"N/A"

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top