IF without ELSE

One Star

IF without ELSE

Hello,
In a tMap, I have want to do a test if without else :
field=toto?YES:<nothing>
Howcan I do that ?
Thank you for answers
Quartz
Community Manager

Re: IF without ELSE

Hi
You can set a default value or null or an empty string for ELSE case, there always be a value for the column even though it is null or empty.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: IF without ELSE

Hi,
if you mean, that data is just mapped in the if case, u can enable the "expression filter" in the tMap component.
Regards,
M
Four Stars

Re: IF without ELSE

Hello,
In a tMap, I have want to do a test if without else :
field=toto?YES:<nothing>
Howcan I do that ?
Thank you for answers
Quartz

Here is what I do to make a field hold a blank value versus a "null" value if value is a String/text:
field=toto ? YES : ""
Here is what I do to make a field hold a blank value versus a "null" value if value is Numeric:
field=toto ? YES : 0
One Star

Re: IF without ELSE

Thank you, Shong,
But, if the value do not change, I want to keep the value original, and if I put it in the else, there is an error.
Have you try to do that ?
Thank you for the help ...
Quartz92
One Star

Re: IF without ELSE

Hi Quartz,
i'm not sure what you exactly want to achieve. But if you want to stick with the old value in the ternary operation use the following:

field='toto'?<set_value_to_sth_else>:field
Regards,
M
One Star

Re: IF without ELSE

Hi,
My problem is different :
In a tMap, with a test (xxx?www:ddd) I want modidy an output field with a value by testing an input field (output fiels is changed with input field or not (then, I keep original output field).
I do not see how I can do that ...
Thanh you for help,
Quartz
One Star

Re: IF without ELSE

Hi,
ah now we're getting a bit clearer. As fair as i understand you will keep the value in your output attribute, but this value is not available in the input component you use (because it's loaded for example from another table).
So in this case you have to provide your output to the tMap as incoming stream. I would suggest the following
tInputXXX1_Check Table (row1)-->
tMap --> tOutput_Output Table (rowOutput)
tInputXXX2_Output Table (row2) -->
Now you can use the ternary operator following
rowOutput.Attribute = row1.Attribute=='someValue'?:row1.Attribute : row2.Attribute
When the if check fails, the existing value from the output component is used.
It might be helpful if you can add a screenshot of the job you modeled so far, then we can get a better understanding.
Regards,
M
One Star

Re: IF without ELSE

Thank-you, mmeier
I did not think to use the same table un input and output.
I try ...
Quartz