Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Help with contains and replace a value.

sreddy01
6 - Meteoroid

Hi Alteryx Community,

 

I need help to find and replace a value in a given column.

 

Sheet1: 

sreddy01_1-1677001395180.png

 

Sheet2:

sreddy01_2-1677001673613.png

 

I want to pick a row from "PLACE" column in Sheet 1 and lookup in "VALUE" column in Sheet 2. If an exact match is found (in any given order), then replace that with "NAME" column from Sheet 1 and leave the extra records as is. I tried doing this with find and replace tool. But there are couple of things that I observed. If there is a mismatch in the order, it is leaving those records. The required output is in Column "Expected Output". And the total count of replaced records here is 8, whereas I am getting 4. Out of which the highlighted 4th row is also an error since it is replacing only those in same order and leaving the others.

sreddy01_3-1677002050142.png

 

Thank you very much for any recommendation.

 

 

 

 

4 REPLIES 4
apathetichell
19 - Altair

Row 4 is not an error per se - you just need to clarify a hierarchical logic. IE in the statement:

 

IF contains ("plant,flower,butterfly") then 1 elseif contains ("plant,flower,butterfly,toyota") then 2, else 3 endif

 

statement 2 logically WILL NEVER BE TRUE. That is because if it was true, statement 1 would be true - and then the Then clause attached to statement 1 would execute. - does that clear it up?

 

To fix this - start with the most restrictive and work your way to the least restrictive...  having said that - I'd probably run a record id, split to rows by comma and then do some kind of match. Then I'd see which components matched and run from there... you'd want to reconfigure your tests into most restrictive - and make sure the components are in alphabetical order.

sreddy01
6 - Meteoroid

Thank you for the response.

I have tried splitting and assigning a record id to it. But I'm not quite sure what to do next. Would you be able to provide a sample wf? Thanks!

apathetichell
19 - Altair

Includes an Iterative Macro to reloop unmatched terms... this matches your output. Assuming your actual data is vastly different make sure that you correct the delimiter and use similair schema conventions.

apathetichell
19 - Altair

I posted this just as the macro - here's the .yxzp.

Labels