Convert String to Integer datatype

Avatar

Avatar
Validate 1
Level 2
tejashriw155148
Level 2

Likes

12 likes

Total Posts

70 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 5
View profile

Avatar
Validate 1
Level 2
tejashriw155148
Level 2

Likes

12 likes

Total Posts

70 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 5
View profile
tejashriw155148
Level 2

28-04-2020

Hi,

 

Please let me know how can I convert string data to integer datatype.

 

Thanks,

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Contributor
MVP
Milan_Vucetic
MVP

Likes

166 likes

Total Posts

386 posts

Correct reply

135 solutions
Top badges earned
Contributor
Springboard
Shape 1
Validate 25
Validate 10
View profile

Avatar
Contributor
MVP
Milan_Vucetic
MVP

Likes

166 likes

Total Posts

386 posts

Correct reply

135 solutions
Top badges earned
Contributor
Springboard
Shape 1
Validate 25
Validate 10
View profile
Milan_Vucetic
MVP

30-04-2020

Hi @tejashriw155148 ,

 

you must do a split after query selection to get two branches (one for INT and another for STRING).

After that you may convert to  preferred type in Enrichment nodes in needed (per branch.)

 

If your data have only two characters you may adapt query in split:

  1. To identify numbers something like: first character in (1,2,3,4,5,6,7,8,9) and second character in (1,2,3,4,5,6,7,8,9)
  2. To identify non-numbers just enable Complement of point 1 to get all non-numbers

 

Generally, with provided data all input values are string. Then you need to separate it with split (above) and do conversion of numbers to integer.

 

Regards,

Milan

Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
MVP
Darren_Bowers
MVP

Likes

90 likes

Total Posts

285 posts

Correct reply

87 solutions
Top badges earned
Validate 1
Affirm 50
Establish
Give Back 3
Applaud 25
View profile

Avatar
Validate 1
MVP
Darren_Bowers
MVP

Likes

90 likes

Total Posts

285 posts

Correct reply

87 solutions
Top badges earned
Validate 1
Affirm 50
Establish
Give Back 3
Applaud 25
View profile
Darren_Bowers
MVP

28-04-2020

Looking at your data below, you cant convert an alpha-based string to an integer. It has to be a numeric string only.

Hard to know what your actual data looks like with that small sample, but if you can assume that the non-numeric data will always start with an alpha character, you can do something like this:

Iif(Ascii(Left(@yourColumn,1)) < 58 and Ascii(Left(@yourColumn,1)) > 47, ToInteger(@yourColumn) , -1 )

This checks the first character to see if it is between 0 and 9. If it is then convert the value to an Integer. Otherwise put "-1" in the data.

 

Avatar

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

126 likes

Total Posts

329 posts

Correct reply

103 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

126 likes

Total Posts

329 posts

Correct reply

103 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile
_Manoj_Kumar
MVP

28-04-2020

Hello @tejashriw155148 

 

You can try ToInt64(<number>) or ToInteger(<number>) depending on your use case.

Thanks,
Manoj