Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.

Alteryx Designer Desktop Discussions

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

Lookup data in another column based on column name in one column

chaitu038
6 - Meteoroid

Hi,

 

   I'm new to Alteryx and trying to find solutions to a problem that's seemingly easy to do in Python.

 

  My table has a set of columns with very generic names with values and another set with meaningful names with generic column name references. The columns with meaningful names are supposed to replace the ones with generic names.

 

Example - 

 

From:

Col XCol Yf1f2q1q2Col ACol BCol CCol D
JM1   f1   
JM2   f1   
JM3   f1   
JN 14   f2  
JN 15   f2  
JN 16   f2  
KO  37   q1 
KO  38   q1 
KO  39   q1 
KP   50   q2
KP   51   q2
KP   52   q2

 

To:

Col XCol Yf1f2q1q2Col ACol BCol CCol D
JM1   1   
JM2   2   
JM3   3   
JN 14   14  
JN 15   15  
JN 16   16  
KO  37   37 
KO  38   38 
KO  39   39 
KP   50   50
KP   51   51
KP   52   52

 

Can you please help me solve this..

 

Due to my organization restrictions, I cannot upload anything.

 

Thanks,

Krishna.

5 REPLIES 5
JoeS
Alteryx Alumni (Retired)

Hi @chaitu038 

 

Not sure if I have missed this slightly.

 

But I have built a process whereby you remove the fields on the top stream that contain the references.

 

Select those same columns in the bottom stream within the transpose tool a data columns.

 

You can then dynamically rename the original columns to their useful name.

 

Workflow.png

AV8
8 - Asteroid

Hi @JoeS

 

Thank you for the solution. Though it was not my query but I was interested in its solution.

 

Am not sure if this solves @chaitu038 's problem. But I was just curious to know how will we handle it if columns containing references(i.e. Col A, Col B etc) contain references to multiple columns. For example if Col A contains reference to f1 in first row and f2 in second row? 

 

 

chaitu038
6 - Meteoroid

Thanks @JoeS for the solution and @AV8 for adding on.

 

@JoeS, sorry I simplified the problem too much. The named columns and unnamed columns don't actually comply.

 

Consider this - 

From:

Col XCol Yf1f2q1q2Col ACol BCol CCol DCol ECol FCol G
JM1 31 f1   q1  
JM2 32 f1   q1  
JM3 33 f1   q1  
JN 14   f2   f2 
JN 15   f2   f2 
JN 16   f2   f2 
KO7 3747  q1 f1 q2
KO8 3848  q1 f1 q2
KO9 3949  q1 f1 q2
KP   50   q2   
KP   51   q2   
KP   52   q2  

 

 

To:

Col XCol Yf1f2q1q2Col ACol BCol CCol DCol ECol FCol G
JM1 31 1   31  
JM2 32 2   32  
JM3 33 3   33  
JN 14   14   14 
JN 15   15   15 
JN 16   16   16 
KO7 3747  37 7 47
KO8 3848  38 8 48
KO9 3949  39 9 49
KP   50   50   
KP   51   51   
KP   52   52  

 

 

Simply put - Alteryx has to lookup the column reference under named columns (Col A, B, etc) and get the corresponding value from the referenced column for that row.

 

I used Python script to do this, but it's not straightforward and due to the volume of data I'm dealing with (26GB file), I had to configure batch macro to process a set of records each time. I'm curious to see if this can be done natively in Alteryx.

 

Thanks for the help,

Krishna.

TonyA
Alteryx Alumni (Retired)

I think this will do it. Let me know if I missed something.

 

2019-10-02_12-17-56.png

 

EDIT: I added some notes to the workflow and changed the output data type to double to match the original data.

chaitu038
6 - Meteoroid

Awesome! Thanks @TonyA for the solution. I had to make only minor changes for my data, but could implement the solution as is for my process.

 

Alteryx processed massive dataset with 9M+ rows & 100 cols like a champ. The pivot step made the data to almost 1.3B rows and 385GB, but it had no problem running the workflow on my 32GB RAM. Just mind blowing.

 

Thanks again for the solution.

 

Krishna.

Labels