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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

IF/else statement usage in tMap

Hi - I have a problem in applying the if/else condition in tMap. I am trying to do below validations in tMap.
if (in.stop_seq == 1 && in.message_status == 10 && in.message_type == 40) 'AA'
else if (in.stop_seq == 1 && in.message_status == 10 && in.message_type == 45) 'X3'
else if (in.stop_seq == 1 && in.message_status == 10 && in.message_type == 50) 'AF'
else if (in.stop_seq == 2 && in.message_status == 10 && in.message_type == 40) 'AB'
else if (in.stop_seq == 2 && in.message_status == 10 && in.message_type == 45) 'X1'
else if (in.stop_seq == 2 && in.message_status == 10 && in.message_type == 50) 'CD'
My source is a db2 and trying to populate a output filed based on this condition. As am new to this, tried all possible options but didn't work. Could you please help?
Note:In my screenshot attached, i tried with one input value to check and populate the target.
Thanks in advance!!!

Labels (2)
32 Replies
Anonymous
Not applicable
Author

Great... it worked for you! 
Anonymous
Not applicable
Author

Hi Sabrina & Umesh,
I have situation ,
I have column which should have only TRUE & FALSE as values but for some records this column having other (1, yes, no...) & null also,
so i want to filter out those records which has other value for this column & i want to put FALSE instead of null only for this column
& if this column is not TRUE or FALSE or Null then it should print as "Value is Different"... plz see below Table for your reference .This is my source data...
ID    BL_Values
1    TRUE
2    FALSE
3    12
4    Yes
5    TRUE
6    TRUE
7    FALSE
8    FALSE
9   
10   
_AnonymousUser
Specialist III
Specialist III

Hi,
I have an issue with the below logic. It is always loading "Processing" regardless for any values of row1.status.
Could anyone help me with the below logic where I am missing
row1.status == "Closed" ? "Complete" : "Processing"
Regards
Saket Krishna
_AnonymousUser
Specialist III
Specialist III

Hi Sabrina & Umesh,
I have situation ,
I have column which should have only TRUE & FALSE as values but for some records this column having other (1, yes, no...) & null also,
so i want to filter out those records which has other value for this column & i want to put FALSE instead of null only for this column
& if this column is not TRUE or FALSE or Null then it should print as "Value is Different"... plz see below Table for your reference .This is my source data...
ID    BL_Values
1    TRUE
2    FALSE
3    12
4    Yes
5    TRUE
6    TRUE
7    FALSE
8    FALSE
9   
10   

if VL_Values is a string datatype not Boolean-
BL.Values == null ? "FALSE " : ("TRUE".equalsIgnorecase(BL.Values) || "FALSE".equalsIgnorecase(BL.Values) ? BL.Values : "Value is different")
msnoeck
Contributor
Contributor

I have a problem with "if-then-else" statement in tMap.
I have created a simpel text file. One of the lines are
0;NL6655/0;NL1091/0;Beschermde Gegevens;Beschermde Gegevens;60,00;17551,50;15;241,33;2008-08-06;0;
I reformated the second column. I have splitted the value NL6655 to NL as code and 6655 as fmid.
I am trying to expand the 6655 with 2 leading 0 so the fmid will be 006655.
But if the code is not NL then it should keep it value.
What I have done is in the tMap Variable the following.

StringHandling.TRIM(row3.code) == "NL" ? String.format("%06d", Integer.parseInt(row3.fmidnum))
:row3.fmidnum .
But then the result is :
.----+----+-------+---------+-------------------+-----+--+--+-----+---+--------.
|                                  tLogRow_2                                   |
|=---+----+-------+---------+-------------------+-----+--+--+-----+---+-------=|
|line|code|fmidnum|sponsor  |contractor         |adres|pp|gp|level|sal|inactive|
|=---+----+-------+---------+-------------------+-----+--+--+-----+---+-------=|
|0   |NL  |6655   |NL1091/0 |Beschermde Gegevens|     |  |  |null |   |null    |.
So no leading zero's before 6655 what I expect.
When I change the code tMap code to :
StringHandling.TRIM(row3.code) == StringHandling.TRIM(row3.code) ? String.format("%06d", Integer.parseInt(row3.fmidnum))
:row3.fmidnum
I get the following result.
|                                  tLogRow_2                                   |
|=---+----+-------+---------+-------------------+-----+--+--+-----+---+-------=|
|line|code|fmidnum|sponsor  |contractor         |adres|pp|gp|level|sal|inactive|
|=---+----+-------+---------+-------------------+-----+--+--+-----+---+-------=|
|0   |NL  |006655 |NL1091/0 |Beschermde Gegevens|     |  |  |null |   |null    |
Their are multiple values for code like XN, BE, NL.
What do i wrong.
Thanks for you reply
gorotman
Creator II
Creator II

Hi msnoeck,
sorry but probably you miss a couple of part from your code (extract the code, extract number portion of the string,...).
This is a working version of your formula:
StringHandling.LEFT(StringHandling.TRIM(strTest),2).equals("NL") ? String.format("%06d", Integer.parseInt(strTest.substring(2,strTest.indexOf("/"))))
bye
Anonymous
Not applicable
Author

hi Sabrina,
 Good day..!
I had a problem can we use assignment operator for non primitive data types...
consider below screen shot, the condition is ((row2.Address_2) == null )?"A":"B" into the column Checking which has been declared as string...But the condition is not working. can any one help me. I got Strucked...
0683p000009M9qx.png

Thanks 
Blessey
Anonymous
Not applicable
Author

The condition looks fine. Are you sure that the Address2 value is not an empty String instead of NULL?
Anonymous
Not applicable
Author

hi rhall,
Nice to see you reply...i just tried with (row3.Address_2.contains(" "))?"A":"B" ..... it works fine
thanks
Blessey
krengan21
Creator
Creator

How to compare and load data between two tables using talend and id with higher value should be loaded from the source ,What condition should i use to do so