Skip to Content
avatar image
Former Member

How to check if field is numeric or not in calculated column

Hello,

I have created a simple attribute view in which I want to check if the KUNNR field is NUMERIC or not and print the result accordingly. There is no IS_NUMERIC function available in string functions so please help to write it with help of IF or CASE statement.

Thanks,

SHriniwas

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jun 01, 2015 at 06:18 PM

    Hello Shriniwas,

    I think you can use the ltrim function in combination with the chars function to check for that.

    With ltrim you can remove the numbers and characters from the left side of the string.

    With chars you count the still available characters after ltrim. If the counted number is greater than 0 it is alpha-numeric, if 0 it is numeric.

    Example:

    if(chars(ltrim("KUNNR",'0123456789')) > 0,'is alpha-numeric','is numeric')

    -> for '120000' -> counter is 0 -> numeric

    -> for '12000A' -> counter is 1 -> alpha-numeric

    -> for 'A20000' -> counter is 6 -> alpha-numeric

    Of course you can adapt the second argument of the ltrim and if function to your needs (e.g. add '+-.' for ltrim in case you check other fields with sign and decimal separator values).

    Best Regards,

    Florian

    Add comment
    10|10000 characters needed characters exceeded