Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
EvoticTalend
Contributor
Contributor

Convert String to Int with a condition

Hello, I have a column said CLICKS (String) that might says "Yes" and other that are all null.

"Yes" values means 1

Null values means 0

EXAMPLE:

CLICKS

1 Yes

2 Yes

3 Null

4 Null

5 Yes

I need this column in INT with numbers because I want to calculate in a BI software later.

¿How can I convert this "Yes" values into a number 1? I need to convert to int and... -- IF (COLUMN CLICKS) COLUMN CLICKS = 1 --

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

try this expression:

row1.CLICKS==null?0:(row1.CLICKS.equals("Yes") ? 1 : 0)

View solution in original post

6 Replies
manodwhb
Champion II
Champion II

@Ivan R​ , You need to use below way in tmap or tjavarow after reading data .

 

row1.CLICKS.equals("Yes") ? 1 : 0

 

 

Thanks,

Manohar

EvoticTalend
Contributor
Contributor
Author

Thank you for the response.

 

I put this code in a row in a tMap but I have a "java.lang.NullPointerException" when I send to a SQL Server DB

0695b00000Gf8AUAAZ.png0695b00000Gf8AZAAZ.png

Anonymous
Not applicable

try this expression:

row1.CLICKS==null?0:(row1.CLICKS.equals("Yes") ? 1 : 0)

manodwhb
Champion II
Champion II

@Ivan R​ ,Agree with @Shicong Hong​ ,it should work.

 

Thanks,

Manohar

EvoticTalend
Contributor
Contributor
Author

Thank You! Works perfectly.

gjeremy1617088143

Hi a simpler solution :

("Yes").equals(row1.CLICKS)?1:0;

Send me Love and Kudos