Jump to content
  • 0

Formula Field Check if INT


pmcfarlain

Question

I want to set up a formula field that can check if a value is an int and if so convert it to an int. How can I verify if a value is an int in the formula is an int? Here's what I tried:

CASE
WHEN ISNUMERIC(RIGHT([@field:Serial_Number], 2))
THEN CONVERT(INT, (RIGHT([@field:Serial_Number], 2)))
END

Any help would be appreciated thanks!

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 2
38 minutes ago, pmcfarlain said:

I want to set up a formula field that can check if a value is an int and if so convert it to an int. How can I verify if a value is an int in the formula is an int? Here's what I tried:

CASE
WHEN ISNUMERIC(RIGHT([@field:Serial_Number], 2))
THEN CONVERT(INT, (RIGHT([@field:Serial_Number], 2)))
END

Any help would be appreciated thanks!

Not sure what the RIGHT is for, you can try this

 

CASE WHEN isNumeric(FIELD) = 1

THEN CONVERT(INT, ROUND(FIELD,0))

ELSE 0

END

it checks if it's numeric (numeric may be INT, Float, etc)

if it is (equal to 1) Then Round the Field to 0 decimal (because INT has no decimal) and convert it to INT(can be omitted, but, just to be sure) to avoid incompatible values when the field's value is in decimal

Else, 0 or any number you want

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...