RonG
June 17, 2019, 7:02am
1
I have a table with two columns
col1 col2
A 1
AB 7
C 23
BD 27
Now i like to create and "if then else "
if the value in col2 <10 then “0” & value in col2
else value of col2
result should be
col1 col2 col3
A 1 01
AB 7 07
C 23 23
BD 27 27
You can do this with the Rule Engine node:
Similar question:
Hi,
I have value in Column A and value in Column B. There are some columns are missing in Column B. I want to create a new column, where it will pick value from Column B and wherever a value is missing, it will pick value from Column A.
Desired output
Column A Column B New Column
ABC ABC
XYZ RAM RAM
DTC TXT TXT
RAM …
Best,
Philipp
2 Likes
RonG
June 17, 2019, 7:58am
3
Hi Philipp,
Have this in the Rule engine node and result in col3
$col2$>9=>$col2$
$col2$<10=>“0” & $col2$
but get an error
if i only put in first formula $col2$>9=>$col2$ there is no error but result is NOT OKE. Result is ?
HansS
June 17, 2019, 8:03am
4
Hi @RonG
An alternative is the string manipulation node (first convert your int to string).
When using length then number leading “0” will be adjust to the max length of your number.
gr
Hans
1 Like
ipazin
June 17, 2019, 12:04pm
5
Hi there,
nice one with the String Manipulation node @HansS ! Although length() function didn’t work Instead I did put number two and it worked.
Additionally @RonG you can use Column Expressions node. Only using Rule Engine won’t work here as it will not add “0” to single digit.
Br,
Ivan
1 Like
HansS
June 17, 2019, 12:28pm
6
@ipazin . It worked on my machine
@RonG Its also possible to make it in 2 Nodes, first length() and then the padLeft , using the outcome of length()
gr. Hans
1 Like
system
Closed
December 17, 2019, 12:28am
7
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.