Multiple If/case Statement in tMap Expression Builder

One Star

Multiple If/case Statement in tMap Expression Builder

I seem to be doing this all the time, whenever there is a simple IF I just put it in the Expression builder eg:
myValue == "test" ? "True" : "False"
Now if I want to have multiple if's in the expression builder I'm having to either create a separate method and call it from the expression builder or use a tJavaRow. Is there a way to do the following in the expression builder directly as it just seems overkill to go out to a separate method/tJavaRow:
if (myValue == "test"){
return "True";
}elseif(myValue == "something else"{
return "False";
}else{
return "True";
}
One Star cri
One Star

Re: Multiple If/case Statement in tMap Expression Builder

Hi,
the following expression should be equivalent to the IF statement you posted:
(myValue == "test") ? "True" :  (  ( myValue == "something else" ) ? "False" : "True" )

The complexer the if statement is, the harder this is to read / understand though :-(
Anyways, hope this helps!

Regards
Christian
One Star

Re: Multiple If/case Statement in tMap Expression Builder

Hello gabbs,
One thing you could do is : myValue == "test" ? "True" : (myValue == "something else")? "False" : "True" that would be a translation of your code above.
Hope it helps!
Highlighted
One Star

Re: Multiple If/case Statement in tMap Expression Builder

Aye someone was quicker Smiley Sad
One Star cri
One Star

Re: Multiple If/case Statement in tMap Expression Builder

Aye someone was quicker Smiley Sad

;-) only a few seconds ... but comforting, to see, that we are of the same oppinion!
One Star

Re: Multiple If/case Statement in tMap Expression Builder

IIF ( (ISNULL(LE_CD) AND (MD_SOURCE_SYSTEM_O='15' OR MD_SOURCE_SYSTEM_O ='16')), OPERATING_UNIT_ID, 
IIF ( (ISNULL(LE_CD) AND (MD_SOURCE_SYSTEM_O = '25' OR MD_SOURCE_SYSTEM_O = '28' OR MD_SOURCE_SYSTEM_O = '27')),
IIF(INSTR(OPERATING_UNIT_NAME_INV_LINE,'-',1) > 0, SUBSTR(OPERATING_UNIT_NAME_INV_LINE,1,(INSTR(OPERATING_UNIT_NAME_INV_LINE,'-',1)- 1))), 
LE_CD))..in talend

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.