Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
ptremblay
Contributor
Contributor

Oracle Decode Function.

Bonjour,
I'm new to TOS.
How can I achieve the equivalent of Oracle's Decode Function within tMap? What is the best way to achieve this in TOS?
Thanks.
PM
Labels (2)
8 Replies
Anonymous
Not applicable

Hello
How can I achieve the equivalent of Oracle's Decode Function within tMap? What is the best way to achieve this in TOS?

Type in the code below in expression filed of tMap 0683p000009MPcz.pngfor example)
row1.supplier_id==1?value1:(row1.supplier_id==2?value2:value3)

Best regards

shong
Anonymous
Not applicable

Or in Perl:
$row1 == 1
? 'value1'
: $row1 == 2
? 'value2'
: 'other'
Anonymous
Not applicable

How can I used following condition in TOS
IIF(upper(STANDING_TAX)= 'GOOD' AND upper(STANDING_RA) = 'GOOD' AND upper(STANDING_OTHER) = 'GOOD' ,'1','2')
I have output field GOODSTD, but I want to check with 3 fields which are shown in above condition.
Anonymous
Not applicable

Hi rahul.nawale
If I understand you correctly, the original expression indicates the result will be "1" if all of the three conditions match, otherwise, it is "2", right?
Shong
Anonymous
Not applicable

yes shong. You are right.
willm1
Creator
Creator

Hi... If you're doing this in tMap which accepts only ternary operators, it'd be:
STANDING_TAX.toUpperCase().equals("GOOD") && STANDING_RA.toUpperCase().equals("GOOD") && STANDING_OTHER.toUpperCase().equals("GOOD") ? "1" : "2"
If in tJava that accepts regular if-then-else, it'd be:

String STANDING_TAX = "";
String STANDING_RA = "";
String STANDING_OTHER = "";
String Output = "";
if (
STANDING_TAX.toUpperCase().equals("GOOD") && STANDING_RA.toUpperCase().equals("GOOD") &&
STANDING_OTHER.toUpperCase().equals("GOOD")
)
{
Output = "1";
}
else
{
Output = "2";
};
System.out.println("Output is... " + Output);
Anonymous
Not applicable

Thanks willm, its working.
willm1
Creator
Creator

Glad to hear... 0683p000009MACn.png