IF else Condition in Mapper
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
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)