×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Extracting portion of field after last -

Extracting portion of field after last -

Extracting portion of field after last -

(OP)
I have a field that is typically populated in the format 12345-67-890 or something similar to that. There are two - characters, however the number of characters can vary. If I wanted to just get everything after that 2nd - . In the above I would want to report 890, what would be the best way to extract that? It typically would be three characters after that last - , but not always.
Thanks!

RE: Extracting portion of field after last -

This will work as long as the field always has exactly 2 "-" characters:

CODE

Split({table.field}, '-')[3] 

Hope this helps

Cheers, Pete

RE: Extracting portion of field after last -

(OP)
Thanks Pete.. I'm getting A subscript must be between 1 and the size of the array . Any thoughts?

RE: Extracting portion of field after last -

It means the data is not as you believe it to be and there is at least 1 row where there is not two "-" characters.

To fix it you will need to add a test to ignore those rows. Amend the formula to this:

CODE

If      UBound(Split({table.field}, '-')) = 3
Then    Split({table.field}, '-')[3] 

Regards

RE: Extracting portion of field after last -

(OP)
Yes - my data wasn't as clean as I hoped... Perfect!! Thank you Again!

RE: Extracting portion of field after last -

If you want the report to clearly indicate the data that is not in the expected format you could use something like the following formula:

CODE

If      UBound(Split({table.field}, '-')) = 3
Then    Split({table.field}, '-')[3] 
Else    'Data not in expected format' 



Pete.

RE: Extracting portion of field after last -

The IF and ELSE results must be of the same data type.

Macola Software Veteran and SAP Business One Consultant on Training Wheels

Check out our Macola tools:

www.gainfocus.biz/exceladdin.html

RE: Extracting portion of field after last -

Hi dgillz. If your comment is in regard to my solution, I think you will find it is. As the original field containing the dashes is a string, the split function result is also a string, albeit a numeric string.

All my solutions are tested to avoid typos etc and it did work.

RE: Extracting portion of field after last -

My apologies I evidently didn't read very well.

Macola Software Veteran and SAP Business One Consultant on Training Wheels

Check out our Macola tools:

www.gainfocus.biz/exceladdin.html

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close