How to write a java script expression in Column Expression

Dear all,

there are two ways how part numbers (in string format) are written for a product category (fruit) in the data set: One way a) is without special characters e.g.

and the second way b) is with special characters (**.-:*)


My goal is to replace all the part numbers of Apples within the column”fruits” with no special characters “.” They all have a length of 11. The conditions for replacing these part numbers are: if in column “fruit” the value is = “Apple” AND if in the column “part number” the part number is without “.” or the length of the part number of Apple is 11 then these part numbers should be replaced this way ( **.-:*). The part numbers of Oranges with “.” should not be replaced

I have tried this in the node Column Expression without any success

I am not sure how to write a javaScript which tells inserts “.” and “-” in certain positions within a string :

if (column(“Brand”)) == “Apple” && length(column(“Part Number”)) == 11))
{???join?? substr?? ),
else { column(“Part Number”)}

Any other solutions are welcome :slight_smile:

Fruit old Part Number correct new Part Number**

Banana 6104020923162 6104020923162
Apple 05.0137-0271.3 05.0137-0271.3
Orange 0.986494927 0.986494927
Apple 05013700093 05.0137-0009.3

Hi @Ashina and welcome to the forum.

I saw a message from you saying were able to find a solution. Do you mind posting a summary of it, or is it confidential to your use case?


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