If however I create two transform components with the exact same entries split, it works fine. So whilst I’ve got this to work, is there is a way of doing this in the one entry so my graph is tidier?
In this trivial case, I’d use switch statement instead:
switch($in.0.Sex){
case "f":
case "F":
$out.0.Sex = "Female";
break;
case "m":
case "M":
$out.0.Sex = "Male";
break;
default:
$out.0.Sex = null;
}
More elegant way, where you might have more “translation” could involve SimpleLookup.
Nevertheless, I’m wondering how rest of your code looks like. Because what you describe should not happen.
Hi all,
thank you for the question as well as the answer. Using the ‘switch’ statement is indeed one of the possible options how to deal with such replacement.
If you want to stick to the ‘replace’ statement that you demonstrated in your issue description, you could also use the following piece of CTL code in the Reformat component:
Note: this example will work in your particular situation with the “Male” and “Female” string, however, it is not generic. There are a handful of more generic approaches such as already mentioned ‘switch’ statement and ‘SimpleLookup’, also ‘if’ statement or some of the other lookups could be used for this purpose in general.