Column Expression rules on the same column

Hello,
I am implementing a number of rules on the same column. Example:
Rule 1:
//remove white spaces where the values are not missing (otherwise I hit null exception)
if (isMissing(column(“HST”))) {“Missing”}
else {strip(column(“HST”))}
The rule replaces the HST column

Rule 2:
//capitalize the word Exempt
if (substr(column(“HST”),0 ,1 )==“E”||
substr(column(“HST”),0 ,1 )==“e”)
{upperCase(column(“HST”))
} else
{column(“HST”)}

Each rule on its own produces the correct results, but they dont work in sequence. Only one of the rules applies. Either I end up with proper capitalization but the word Missing is not there; or if I change the order of the rules, I end up with Missing value but Exempt is not capitalized.

How come? Looking forward to your suggestions, smart people :slight_smile:

if (isMissing(column(“HST”))) {“Missing”}
else {
if (substr(strip(column(“HST”)),0 ,1 )==“E”||
substr(strip(column(“HST”)),0 ,1 )==“e”)
{upperCase(strip((column(“HST”))
} else
{strip(column(“HST”))}
}

1 Like

Thank you! That will do the trick.
I do wonder however why it dows not work as a2 separate rules in column Expression node. Do i have to pack all rules for one column i to one rule for that node? Does the node not perform rules in priority? And if it does, why doesnt it work on the same column? Maybe it is a bug?

Maybe you could give an example in a workflow then we could check what it does

Hi,

Each expression that you add to the “Column Expressions” node will be applied to the input data regardless of the output of the other expressions.
So in your case for example, each expression does its job but they are applied to the input and if you are replacing the same column, the latter will be the final output that you get.

As you can see, @izaychik63 combined the two expressions in one expression so it works as you expected.

Best,
Armin

2 Likes

Got it, so the Column Expression allows rules on multiple columns but all rules for one column should be in the same expression. Thank you for the clarification!

2 Likes