Skip to Content
0

How to change VARCHAR to INT using calculated column.

Mar 06, 2017 at 10:04 AM

102

avatar image

I have a VARCHAR column in a table having only numbers and Blank spaces. I need to convert this column as Integer, but the problem I am facing is with the Blank Space. I need to convert that to NULL, which I am not able to do. I can't alter the table as well.

I am running HANA SPS 12.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Florian Pfeffer
Mar 06, 2017 at 01:44 PM
0

You can use following to convert your values to an Integer and blank values to a Null value.

if(trim("COLUMN") = '', NULL, int("COLUMN"))

Regards,
Florian

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Florian,

I tried your solution. While validating, it's showing "valid expression". But while data preview I am getting the bellow error

sap.jpg (33.6 kB)
0

Seems like you do not have only blank and integer values in your table. So you have to deal with that things in the formula by excluding them or converting them to valid values.

0