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.
SOLVED

Compare ID from two datasets and create a new column

ssrip4
6 - Meteoroid

Hello community,

 

I am trying to map data from two places, one is the data from a CSV file and other is data retrieved from a database.

 

CSV Data

 

IDNameAction
101-ABC-6ZXAlphaA
102-ABC-6XZBravoA
103-ABC-6CVCharlieR
104-ABC-6BNDeltaD

 

Database Data

 

IDCode
101-ABC-6ZXESC1
103-ABC-6CVESC2
104-ABC-6BNESC3
105-ABC-6NMESC4

 

Result Data in CSV

 

IDNameActionChange
101-ABC-6ZXAlphaARevise
102-ABC-6XZBravoAAdd
103-ABC-6CVCharlieRRevise
104-ABC-6BNDeltaDDelete

 

Now, I am trying to compare the ID data from CSV with the data from DB across all the rows to find a match.

 

Then, I would like to add a new column called Change based on a formula.

 

1) If ID from CSV matched the ID from DB and the "Action" column is "Not Equal to D" then the change should be "Revised". If it equals to "D" then it should be "Delete".

2) If the ID from CSV is not found in the ID from the DB and the "Action" column is "Equal to A" then the change should be "Add".

 

Can anyone help me with this?

Thank you

2 REPLIES 2
Luke_C
17 - Castor
17 - Castor

Hi @ssrip4 

 

Here's how I'd approach this:

 

  1. Join the data together on ID
  2. Union the fallouts from the csv (this gives the effect of a left outer join)
  3. Use an IF statement to assign your change logic

 

Luke_C_0-1679935671508.png

 

ssrip4
6 - Meteoroid

Hello @Luke_C, thank you for the help. It works perfectly

Labels