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: 
Anonymous
Not applicable

tmap variable field not allowing simple expression

I have a field called row1.ActionCode.
I try to add a variable: row1.ActionCode == "UP"
It gives me compile error.  "cannot convert from boolean to string".  ActionCode is a string - the code completion helper told me so. 
When I typed in row1. it gave me an option to pick ActionCode so I know it's there.

Labels (2)
3 Replies
Anonymous
Not applicable
Author

Hi 
Where do you write this expression? Can you please upload a screenshot of tMap?

Regards
Shong
JR1
Creator III
Creator III

What exactly do you want your variable to hold? If you just put row1.ActionCode == "UP" in it, it will always return a Boolean value and for other reasons it will most likely always be "false". If you have configured your variable as a string, the mentioned error will occur. By the way: the expression will always return false as - simply speaking - Java does not compare the values but whether it is the same object. As row1.ActionCode is never the same object as the (new) string "UP", it will always return false. If you want to compare values, you would have to use the following expression: "UP".equals(row1.ActionCode).
cterenzi
Specialist
Specialist

As others have pointed you, you're using a test as an output.  If you want a specific output when ActionCode is "UP", you'll probably want something like:
"UP".equals(row1.ActionCode) ? "True" : "False"
(replace "True" and "False" with whatever you want to appear for those particular cases)