03-31-2021 12:18 PM
Hi ,
I have a requirement to write multiple IF/ELSE conditions and generate an output column. but i am getting syntax error, please someone correct me
$section == “Presentation” && $action_field == “Product Short Name” ? $EMA_PRODUCTSHORTNAME:
$section == “Presentation” && $action_field == “Product INN/Common Name” ? $EMA_PRODUCTGENERICNAME:
$section == “Presentation” && $action_field == “Product Strength Name” ? $EMA_PRODUCTSTRENGTH:
$section == “Presentation” && $action_field == “Full Presentation Name” ? $EMA_PRODUCTNAME:
$section == “Presentation” && $action_field == “Product Form Name” ? $EMA_PRODUCTFORM:
$section == “Authorisation” && $action_field == “Orphan Drug” ? $ORPHANDRUG:
$section == “Authorisation” && $action_field == “Authorisation Number” ? $EMA_AUTHORISATIONNUMBER:
$section == “Presentation” && $action_field == “Product Company Name” ? $EMA_PRODUCTCOMPANYNAME: null
Thannks
Solved! Go to Solution.
03-31-2021 03:59 PM
To follow up with a little additional help (barring any typos)…
1 ) The ternary code you provided above needs parenthetical grouping:
$section == "Presentation" && $action_field == "Product Short Name" ? $EMA_PRODUCTSHORTNAME:
($section == "Presentation" && $action_field == "Product INN/Common Name" ? $EMA_PRODUCTGENERICNAME:
($section == "Presentation" && $action_field == "Product Strength Name" ? $EMA_PRODUCTSTRENGTH:
($section == "Presentation" && $action_field == "Full Presentation Name" ? $EMA_PRODUCTNAME:
($section == "Presentation" && $action_field == "Product Form Name" ? $EMA_PRODUCTFORM:
($section == "Authorisation" && $action_field == "Orphan Drug" ? $ORPHANDRUG:
($section == "Authorisation" && $action_field == "Authorisation Number" ? $EMA_AUTHORISATIONNUMBER:
($section == "Presentation" && $action_field == "Product Company Name" ? $EMA_PRODUCTCOMPANYNAME: null)))))))
2 ) Here is an example of the same in a match statement(s):
match $section {
"Presentation" => match $action_field {
"Product Short Name" => $EMA_PRODUCTSHORTNAME,
"Product INN/Common Name" => $EMA_PRODUCTGENERICNAME,
"Product Strength Name" => $EMA_PRODUCTSTRENGTH,
"Full Presentation Name" => $EMA_PRODUCTNAME,
"Product Form Name" => $EMA_PRODUCTFORM,
"Product Company Name" => $EMA_PRODUCTCOMPANYNAME,
_ => null
},
"Authorisation" => match $action_field {
"Orphan Drug" => $ORPHANDRUG,
"Authorisation Number" => $EMA_AUTHORISATIONNUMBER,
_ => null
},
_ => null
}
3 ) Here is a sample pipeline showing the Conditional Snap compared to the ternary and match mapper options: Community.9753.slp (15.6 KB)
04-01-2021 12:30 AM
Hi Del,
Thanks for the example and i will try with your inputs and will also try with Conditional Snap.
Thanks Again.
04-01-2021 03:18 AM
It worked, thanks a lot Del.