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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Radnip
Contributor
Contributor

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";
}
Labels (3)
6 Replies
Anonymous
Not applicable

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

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

Aye someone was quicker 0683p000009MPcz.png
Anonymous
Not applicable

Aye someone was quicker 0683p000009MPcz.png

😉 only a few seconds ... but comforting, to see, that we are of the same oppinion!
Anonymous
Not applicable

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
Radnip
Contributor
Contributor
Author

LOL just searched for the same question... and look what just popped up... answers to the question I asked 12 years ago. But looks like I never said thanks... so a belated 12 year thanks to @Remi Masri​ @Christian Riedel​ 😁