Expected result not coming in terenary operator

Seven Stars

Expected result not coming in terenary operator

Hi,

 

Relational.ISNULL(row1.name)?null:
(("DMD").contains(row1.name)?"drug device":
(("MD").contains(row1.name)?"medical device":
(("MD,DMD").contains(row1.name)?"medical device,drug-device":
"drug")))

 

i have written my code like this but whatever condition i give i am getting the result only "drug" please help out where i am missing ,

my expected result is

if column contains,

DMD=drug device

MD=medical device

MD,DMD or DMD,MD= medical device,drug-device

other than above thre conditons it should give "drug"

 

please help out

 

Regards,

murala

 

 


Accepted Solutions
Forteen Stars

Re: Expected result not coming in terenary operator

@muralam,check this.

 

row3.name==null ? row3.name : row3.name.contains("MD,DMD") ? "medical device,drug-device" : row3.name.contains("DMD") ? "drug device" :row3.name.contains("MD") ? "medical device" : "drug"

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.

All Replies
Forteen Stars

Re: Expected result not coming in terenary operator

@muralam,are you lokking for the following.

Untitled.png

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Fifteen Stars TRF
Fifteen Stars

Re: Expected result not coming in terenary operator

Not sure that "DMD" can contain the row1.name value nor "MD".

Also, the last test must become the 1rst one:

 

Relational.ISNULL(row1.name) ? null : 
     row1.name.contains("MD,DMD") ? "medical device,drug-device" :
          row1.name.contains("DMD") ? "drug device" :
               row1.name.contains("MD") ? "medical device" : "drug"

 

 

 


TRF
Forteen Stars

Re: Expected result not coming in terenary operator

@muralam,below is the condition.

 

 

row3.name==null ? row3.name : row3.name.equals("DMD")? "drug device" : row3.name.equals("MD")? "medical device" :row3.name.equals("MD,DMD")?"medical device,drug-device" : "drug"

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Forteen Stars

Re: Expected result not coming in terenary operator

@muralam,can try this also.

 

row3.name==null ? row3.name : row3.name.contains("DMD")? "drug device" : row3.name.contains("MD")? "medical device" :row3.name.contains("MD,DMD")?"medical device,drug-device" : "drug"

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Seven Stars

Re: Expected result not coming in terenary operator

@manodwhb,

 

Thanks for quick reply, but my coulmn value contains some different string too 

for example

"DMD,MK,HCT" for this value i should get the result "drug device" i am not sure if .equals works this case

Forteen Stars

Re: Expected result not coming in terenary operator

@muralam,you can go with .

row3.name==null ? row3.name : row3.name.contains("DMD")? "drug device" : row3.name.contains("MD")? "medical device" :row3.name.contains("MD,DMD")?"medical device,drug-device" : "drug"

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Seven Stars

Re: Expected result not coming in terenary operator

yes @Manohar B
Seven Stars

Re: Expected result not coming in terenary operator

@manodwhb,
row3.name.contains("MD,DMD")?"medical device,drug-device" this confition is not satisfying output is coming as "drug device " but not "medical device,drug-device"
Forteen Stars

Re: Expected result not coming in terenary operator

@muralam,check this.

 

row3.name==null ? row3.name : row3.name.contains("MD,DMD") ? "medical device,drug-device" : row3.name.contains("DMD") ? "drug device" :row3.name.contains("MD") ? "medical device" : "drug"

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Seven Stars

Re: Expected result not coming in terenary operator

@manodwhb,

 

Thanks for your prompt response

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Definitive Guide to Data Quality

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

Download