Six 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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Twelve 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
10 REPLIES
Twelve Stars

Re: Expected result not coming in terenary operator

@muralam,are you lokking for the following.

Untitled.png

Manohar B
Forteen Stars TRF
Forteen 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
Twelve 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
Twelve 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
Six 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

Twelve 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
Six Stars

Re: Expected result not coming in terenary operator

yes @Manohar B
Six 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"
Twelve 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
Six Stars

Re: Expected result not coming in terenary operator

@manodwhb,

 

Thanks for your prompt response