Skip to main content

Formula to find if a field contains a number

  • April 14, 2023
  • 1 reply
  • 213 views

Forum|alt.badge.img+2
  • Participating Frequently
  • 7 replies

Hoping someone can assist me in creating a formula. 

Basically I want to take a field that has a numeric value in it and convert it to CM or if there is no number in that field output the text that is in it. 

e.g.

Field A contains value: 60 or contains value "not applicable".

Using a formula field I have 

{Field A} & " in, " & ROUND(VALUE({Field A}) * 2.54) & ' cm'.
 
The output would be "60 in, 152, cm" if it just contained numbers.
 
If that field instead contained text and no numbers I want to just output the text. It won't always be "not applicable" that's just an example. So I figure I might have to use the search() function with regex in the formula with an IF statement. So basically "if "field a" does not contain a number just output text".
 
Just not really sure how to do it! Any help would be great. 

1 reply

Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • 7 replies
  • April 14, 2023

Actually, think I figured it out:

 

IF(REGEX_MATCH({Field a}, "[0-9]"), {Field a} & " in, " & ROUND(VALUE({Field a}) * 2.54) & ' cm', {Field a})