Page 1 of 1

Test a text field for numeric values

Posted: 24 Apr 2026, 12:45
by KenStarnes
Hi
Is there any way in RW you can test a field for numeric values ?
A PO analysis field is being used under certain circumstances for a numeric identifier but can also be text or blank.
I've got a check based on length of the field <> 0 to see if it has any data in it but if it's numeric I'd like to do a a calculation on it otherwise leave it.

If it's not possible then exporting to Excel and doing it there may be the answer

Re: Test a text field for numeric values

Posted: 24 Apr 2026, 14:34
by brucedenney
If the number is not 0 then you could convert the field to a number and see if it is greater than zero

Re: Test a text field for numeric values

Posted: 28 Apr 2026, 12:02
by KenStarnes
Thanks Bruce

I ended up with 2 Expressions

Expr3 = Length(PURCHASE_ORDER.ANALYSIS_1) <> 0 ? Substring(PURCHASE_ORDER.ANALYSIS_1,0,1):"-"

Expr2 = Expr3 <> "-" ? Expr3 <= "9" ? StringToInteger(PURCHASE_ORDER.ANALYSIS_1) : 0 :0

Could I have done this more efficiently ?

Re: Test a text field for numeric values

Posted: 28 Apr 2026, 13:14
by brucedenney
this is the most simple method

StringToInteger(PURCHASE_ORDER.ANALYSIS_1)

Returns 0 if not a number else the number.

Re: Test a text field for numeric values

Posted: 28 Apr 2026, 15:26
by KenStarnes
I'd tried that but it wouldn't return 0 if non-blank and not numeric ie something like ABC in the field also. It failed with an error.
I assume that test only works if there's a numeric value or nothing.

I'm on v29 btw