Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Edi1
Contributor
Contributor

Please verify syntax is formatted correctly

Is this Talend syntax correct or am i missing a variable?

row1.Post_Key() == debit? "60" : "70"

Labels (2)
1 Solution

Accepted Solutions
gjeremy1617088143

HI Edi, glad you succeed ! you don't have to use String.valueOf() method it's already a String, and you can use the folowing syntaxe to make it null safe : "Debit".equals(row1.Post_Key)?"60":"70"

View solution in original post

22 Replies
gjeremy1617088143

Hi could you explain the debit field ?

if debit is a string and row1.Post_Key() is a string you should use : row1.Post_Key().equals("debit")? "60" : "70"

Edi1
Contributor
Contributor
Author

Hi, Thanks for your reply. Yes, I have it as a string 60 is debit and 70 is credit. Should I add "credit" in front of 70? Like this.... row1.Post_Key().equals("debit")? "60" : (" credit")"70"

gjeremy1617088143

Hi Edi, first point it's weird to have parenthesis in your column name (Post_Key() you should avoid this in your column name),

so if row1.Post_key() is a string and is value is "credit" or "debit" and your corresponding output value is "60" or "70" then :

row1.Post_Key().equals("debit")? "60" : "70"

 

if if row1.Post_key() is a string and is value is "60" or "70" and your corresponding output value is "debit" or "credit" then :

row1.Post_Key().equals("60")? "debit" : "credit"

 

it depend of wich value you have in input and wich value you want in output.

 

Edi1
Contributor
Contributor
Author

Excellent! Thanks gjeremy. This will be helpful for me to assist me with updating it.

Edi1
Contributor
Contributor
Author

Hello!

I am getting an error message that it cannot convert from boolean to string. Can you please help me with this syntax to resolve error?

I tried this at first:

row1.Post_Key().equals("debit")? "60" : "70"

 

I received error above cannot convert from boolean to string so I cast to a string like this, below. It is still not working. I am getting error as stated above.

((String) row1).Post_Key().equals("debit")? "60" : "70" 

 

Help please!

gjeremy1617088143

Where are you using it? In a Tmap ?

gjeremy1617088143

if it’s in a tMap could you send screenshot of the tMap and input output schema ?

gjeremy1617088143

If you want to convert boolean to String use: String.valueOf(Your boolean) instead of (String)(your boolean), but result will be « true » or « false »

Edi1
Contributor
Contributor
Author

Yes, in tMap