Condtionally Replacing Values in a Column

Hi Thank you.
could you pls help me with this problem?
In a column we have some cells equal to zero, and we want replace them with values that are in an other column.
for example,
we want replace column Ship to Code zero with Sold To Code:

Do you have any suggestion?
Thk in advance
Simone

Hi @SimoneDePaoli -

I made a new topic for your question to keep things tidy.

In this case you could use a Rule Engine node with code like this:

$Ship to Code$ = 0 => $Sold to Code"
TRUE => $Ship to Code"

Making sure to also set the Replace Column option to “Ship to Code”

3 Likes

hi @ScottF,

I’ve tried to make it, but doesn’t work.

the columns have to be string or number?

thank you in advance.

Simone

Hi there @SimoneDePaoli,

you are getting error or wrong results? Can you give us print screen of your Rule Engine configuration node?

Br,
Ivan

i tried again and now works, but in this case when the $ship to code$ is different from zero, the result is taking to ship or sold?

thank you!

Hi @SimoneDePaoli,

above rules from @ScottF mean following:
If value in column “Ship to Code” is zero take value from column “Sold to Code”. In any other case take value from column “Ship to Code”.

What might help your understanding is that “The first matching rule in order of definition determines the outcome.”

Hope this clarifies things :slight_smile:

Br,
Ivan

1 Like

Hi @ipazin,

i’ll share with you the rule engine screenshot and the outcome:

2)

I’d like to have as outcome the number as the first cell, may you help me how to do it?

thank you in advance.

Simone

Hi there @SimoneDePaoli,

not sure I understand. Your rules are ok. Second row of Ship to Code is a big number but column is String. Maybe String to Number node can help but how did you end up with String column? How does you workflow looks like?

Br,
Ivan

1 Like

Hi there,

i’ve used the string to number node, look likes to work.

thank you.

Simone

1 Like

Hi @SimoneDePaoli,

just to share where String type column comes from. Your “Sold to Code” column is String and in Rule Engine “the type of the outcome column is the common super type of all possible outcomes”. That explains it.

Br,
Ivan

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