cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

IF else Condition in Mapper

pranil2k2
Contributor

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

1 ACCEPTED SOLUTION

del
Contributor III

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)

View solution in original post

6 REPLIES 6

Hi Del,

Thanks for the example and i will try with your inputs and will also try with Conditional Snap.

Thanks Again.

pranil2k2
Contributor

It worked, thanks a lot Del.