Right function starting at specific character

i have the following field that varies in lenght and need to do a right function based on everything after the "-"

example of fields:
123456-knoxville
85632547-charlotte
22222-Chattanooga


want it to return:
knoxville
charlotte
Chattanooga
kelsanitAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try

MID({myField}, INSTR({myField }, " ") + 1, LEN({myField})-( INSTR({myField }, " ") + 1))

Open in new window


Regards
0
kelsanitAuthor Commented:
here is what i entered as "myfiedld" is  {@EquipmentID}
MID({@EquipmentID}, INSTR({@EquipmentID}, " ") + 1, LEN({@EquipmentID}-(INSTR({@EquipmentID}, " ") + 1)))

Get error " A number, currency amount, date, time or date time is required
0
mlmccCommented:
Assuming there is always a - in the text use

Split({@EquipmentID},'-')[1]

mlmcc
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

mlmccCommented:
You have the ( ) paired in the wrong places.  Try that this way

MID({@EquipmentID}, INSTR({@EquipmentID}, " ") + 1, LEN({@EquipmentID}) - INSTR({@EquipmentID}, " ") + 1)

mlmcc
0
kelsanitAuthor Commented:
Tried the first fuction SPLIT and got the following error "A subscript must be between 1 and the size of the array"
Split({@EquipmentID},'-')[1]

Tried the other MID function and returned the full text.
MID({@EquipmentID}, INSTR({@EquipmentID}, " ") + 1, LEN({@EquipmentID}) - INSTR({@EquipmentID}, " ") + 1)
0
mlmccCommented:
THe INSTR needs to search for  -

MID({@EquipmentID}, INSTR({@EquipmentID}, "-") + 1, LEN({@EquipmentID}) - INSTR({@EquipmentID}, "-") + 1)

the subscript error indicates some don't have a - or are NULL

If InStr({@EquipmentID}, "-")  > 0 then
     Split({@EquipmentID},'-')[2]
Else
     {@EquipmentID}

Open in new window


What is the {@EquipmentID} formula?

mlmcc
0
kelsanitAuthor Commented:
if {RS_ROUTE_EQUIPMENT.EQUIPMENT_ID}="-" then "" else {RS_ROUTE_EQUIPMENT.EQUIPMENT_ID}
0
kelsanitAuthor Commented:
Used the equipmentid field in the table and the split function worked.  Thank you
0
kelsanitAuthor Commented:
found one more issue.

there are sometimes two "-" in the text field how do I make sure i always get the text after the last dash?

example:

487-156-knoxville
12345-knoxville

desired output:
knoxville
knoxville
0
mlmccCommented:
Try this with the split

Split({RS_ROUTE_EQUIPMENT.EQUIPMENT_ID},'-')[UBound(Split({RS_ROUTE_EQUIPMENT.EQUIPMENT_ID},'-')]

mlmcc
0
James0628Commented:
FWIW, another way to get everything after the last "-" would be:

Mid ({RS_ROUTE_EQUIPMENT.EQUIPMENT_ID}, InStrRev ({RS_ROUTE_EQUIPMENT.EQUIPMENT_ID}, "-") + 1)

 If the field could be null, you could add a check for that.

 James
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.