Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hi All,
Is there a way to recode specific string value based on other column values? for exmaple I have 1000 rows, I know that out of all those I want to recode only specfic products (in my case I have 2 products with the same name, and I want to make them distinct adding a group for them (but only for them). Something like on a screen below:
Thank you,
eM
OK, nevermind.... ๐
if (Products=="A" && GROUP=="1", 'A', 'A1')
if (Products=="A" && GROUP=="2", 'A', 'A2')
*** OR maybe no.... when I used this formula in my 'real data' it recoded all values in Product Column to a A1.. hmm.
*** LAST UPDATE - sorry I already found the solution:
if(condition, then, else) so the syntax will be:
if(Group=="1", replace(Products, "A", "A1"),Products)
Hi,
To do this you will need to go through 2 visual recipes. The first step is to do a Window recipe to count the number of rows for a specific Product code.
Open a window recipe and set it up as below - Partitioning on your Product column and Count aggregation on your Product column (here it's Col1 in my example)
You will end up with a dataset that should look like this:
From there, open a Prepare recipe and use a Formula processor to create your Products after recode with a syntax like below:
Hope this helps
OK, nevermind.... ๐
if (Products=="A" && GROUP=="1", 'A', 'A1')
if (Products=="A" && GROUP=="2", 'A', 'A2')
*** OR maybe no.... when I used this formula in my 'real data' it recoded all values in Product Column to a A1.. hmm.
*** LAST UPDATE - sorry I already found the solution:
if(condition, then, else) so the syntax will be:
if(Group=="1", replace(Products, "A", "A1"),Products)
Hi,
To do this you will need to go through 2 visual recipes. The first step is to do a Window recipe to count the number of rows for a specific Product code.
Open a window recipe and set it up as below - Partitioning on your Product column and Count aggregation on your Product column (here it's Col1 in my example)
You will end up with a dataset that should look like this:
From there, open a Prepare recipe and use a Formula processor to create your Products after recode with a syntax like below:
Hope this helps
Thank you for another way to approach this.
As for now, I think, since I know what specific product I am looking for, and that won't change I guess I can stick to my solution? Your way is much safer if I would not have idea how much products are like that, and when that can change over time.