How to check if field is numeric or not in calculated column
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.
Florian Pfeffer replied
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.
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).