Skip to Content
author's profile photo Former Member
Former Member

Extract Number from string

I need to extract the number, if it exists, from an alphanumeric text string. I am told that the first two characters will be alpha and the remaining character(s) will be numeric, if the numeric exists at all.

I know this is a simple formula, but I can't quite get it.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 12:30 AM

    Here is a change to my formula.

    whilereadingrecords;

    if length(Your data field) (not equal symbols) 0 then

    if numerictext(mid(Your data field,3,length(Your data field)-2)) then

    tonumber(mid(Your data field,3,length(Your data field)-2))

    Else

    0

    Else

    0

    Once you have the formula you should be able to insert a summary field on the formula

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 14, 2009 at 07:21 PM

    Are the two alpha and remaining numeric characters always in the same position within the string?

    Are the two alpha characters always going to be the same?

    Is the length of the numeric value following the two alpha characters always going to be the same?

    The more no answers you have to the above the tougher it will be!

    Get back with the above answers and possibly copy and paste some examples of the ENTIRE strings from which you will be extracting the values and let us know which are the values you'll be pulling from within the larger string.

    "I need to extract the number, if it exists, from an alphanumeric text string. I am told that the first two characters will be alpha and the remaining character(s) will be numeric, if the numeric exists at all.

    I know this is a simple formula, but I can't quite get it."

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 14, 2009 at 07:24 PM

    Try this.

    Mid (str, start,length)

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 14, 2009 at 07:24 PM

    try this

    if length(Your data field) (not equal symbols) 0 then

    if numerictext(mid(Your data field,3,length(Your data field)-2)) then

    mid(Your data field,3,length(Your data field)-2)

    Edited by: Zilla Eh on Jan 14, 2009 8:25 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 14, 2009 at 07:32 PM

    Hi Adele

    If only the first two characters are alphabetic, then you can try the following formula:

    Replace ({field name}, left ({field name}, 2),'')

    Hope this helps!

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Now that I have the number, I need to sum them. What's the best way to convert it to a number? I tried making it a numbervar and then converting ToNumber, but that didn't work. As you can tell, I'm not real clever on formulae and conversions.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 12:36 AM

    Follow up email solved the number conversion, too

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 12:39 AM

    Follow Up question resolved the number conversion part of the problem

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.