We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Merging (updating) datasets

iwilliams
8 - Asteroid

I am joining data from 2 different sources and I need to use the 2nd source to update the first.  The first data source is some database data and the second data source is a csv with items that need to be updated within the database data (these updates could be new rows, changes in value to existing rows, etc.).  The first source has 50+ columns and the second source will have varying amounts of columns.  

 

I need to join/merge these two data sources and overwrite values from the database with the values in the csv when the column names are the same and add in any data that is missing

 

Ex:

 

DB

keycol1col2col3col4col5
10300string1nullnull
21250string2 nullnull
31200string3nullnull
40225string4nullnull

 

csv

keycol2col3new col
275string twob
325string threec
550string fivee

 

output

keycol1col2col3col4col5new col
10300string1nullnullnull
2175string twonullnullb
3125string threenullnullc
40225string4nullnullnull
5null50string fivenullnulle

 

 

I need for this to be pretty dynamic since the columns that are updated will vary and also because of the amount of columns in the db.  If anyone has any thoughts on this or can provide any insight on how I could do this it would be greatly appreciated.

 

4 REPLIES 4
atcodedog05
22 - Nova
22 - Nova

Hi @iwilliams 

 

Use join, union and dynamic select tool combination like below. It should dynamically accommodate new columns. If it doesn't let me know.

 

Workflow:

atcodedog05_0-1641318769884.png

 

Hope this helps : )

 

iwilliams
8 - Asteroid

Hello @atcodedog05 thanks for the quick reply.  Your solution is not quite what I am looking for. In the final output the col2 should have the updated values for 2 and 3 (250->75 and  200->25) and in col3 there should be updates for 2 and 3 (string2->string two and string3 -> string three).  

The last thing I tried to do try fix my issue was to take columns that have the "right_" or "input #2" prefix and use a formula to update the corresponding column without the prefix - but I struggled with finding a dynamic way to do this 

 

So just as an example, after the join we would have some duplicate columns and I could try and take two columns like this:

col2Right_col2
300 
25075
20025
225 
50 

 

Then use if-then formula to update col2 and after that I can discard Right_col2

col2Right_col2
300 
7575
2525
225 
50 

 

But as I said before this would have to be done dynamically for each column with a corresponding "Right_" or "Input #2" match and I haven't figured out how to do so far

iwilliams
8 - Asteroid

reversing the order of the inputs gave the desired output, thanks for your help

 

 

atcodedog05
22 - Nova
22 - Nova

Happy to help : ) @iwilliams 

Cheers and have a nice day!

Labels
Top Solution Authors