Can the Rule Engine node understand string numerals as integers?

If I have a string column Col5 full of number values (0,2,22,5, etc), and only numbers (no text), can Rule Engine node then understand these numbers as integers, such that a rule like the following will work?

$Col5$ < 5 => “Green”

Or do I have to express the rule as:
$Col5$ IN (“0”,“1”,“2”,“3”,“4”) => “Green”

?

Thanks for any insights.

Mick

Hi @Mick , if they are string, then they will be treated as string.

This means that if you are doing comparison such as < or >, it will validate this as alphabetical order, meaning that “22” is actually < “3”. “03” would be < “22”.

This means that $Col5$ < 5 => "Green" will not give you the expected results.

$Col5$ IN ("0","1","2","3","4") => "Green" would work for what you are trying to do.

Is there any reason why the Col5 is of type string? I would recommend changing it to integer if it’s purpose is to hold integers, and then you would be able to use $Col5$ < 5 => "Green"

2 Likes

Thank you for the explanation Bruno, now I know why it ‘works’ sometimes and not other times. In fact the column that I am processing contains all the answers for a questionnaire, where some questions require an integer answer and others a string answer - so overall the ‘Answer values’ column is typed as ‘string’. I can see now that I will have to use Row Splitter to separate the integer answers from the string answers, then process them via separate Rule Engine nodes, then recombine them at the end. Thanks again…

1 Like

No problem Mick, happy to help

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.