cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor

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

0 Kudos

Thanks a lot Florian.


It's working. 🙂

Thanks,

Shriniwas

Answers (0)