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

Complex Join

Rhael012
6 - Meteoroid

I have a problem joining two of my dataset. One main problem is there is no primary key for the two dataset since there are duplicate records with both sets. I'm trying to get supplemental data from the Table 2 to the Table 1. 

 

Table 1:

RecordDetails
1 
1 
2 
2 


Table 2:

RecordDetails
1Detail 1
2Detail 2
2Detail 3
2Detail 4
3Detail 5

 

Result should be like this:

RecordDetails
1Detail 1
1 
2Detail 2
2Detail 3

 

Thanks for the help.

14 REPLIES 14
CathyS_Slalom
9 - Comet

Hi @Rhael012, I'm trying to understand your end goal. So although you have Detail 4 assigned to Record 2, because you only have 2 rows from table 1, your end results won't have the Detail 4?

CathyS_Slalom
9 - Comet

Hi @Rhael012, based on the assumption that I made earlier, see attached workflow. You can use the multi-row to create a rank column that way, you have a unique composite key to join on, and then union it together to have the desired results. 

cathyshi525_0-1649452874079.png

 

 

 

Qiu
21 - Polaris
21 - Polaris

@Rhael012 
Maybe we can use Tile tool to generate the primary key? 😁

0409-Rhael012.PNG

apathetichell
19 - Altair

Just chiming in here to support @Qiu 's suggestion of Tile tool. It's very helpful in creating fake primary keys to prevent expanding joins.

Qiu
21 - Polaris
21 - Polaris

@apathetichell 
Thank you.
I also somehow like the Tile Tool. 😁

Rhael012
6 - Meteoroid

Hi @cathyshi525, to give context on what I'm trying to do. On a previous day, there are multiple transactions that is look alike. When those transactions has been reviewed, there will be additional details inputted on each of those transactions. What I'm trying to achieve is to get the details of those transaction from the previous day based on the current date transaction. There will be some transactions that was closed on the previous day. Thus, when we check the current day transactions, some of those transactions will not be generated from the system. 

The logic is like this, get all transactions for this day, check each transactions if there is a previous record from the previous day. If there is, get the details from those transactions. Hope this helps to clarify what I'm trying to do. Thanks

apathetichell
19 - Altair

Hi - This sounds like a self-join where you take the current day - create a field for previous day. And then do a self join where on current day/transaction id and previous day/transaction id. The resulting join anchor will be entities which had a matching reference yesterday.

Rhael012
6 - Meteoroid

Hi @Qiu, this solution looks promising. But I am not getting my desired output. 

Let's say I have 20k records on Table 1 which may have duplicate records and I have 38k records on Table 2 which also have duplicate records. 

Although Table2 has many records, I only need the output to be exactly how many records in Table 1.

The tricky part here, is even though some of the records are look alike since they don't have a primary key, each records are treated as unique because of the details that I'm trying to get from Table 2 to supplement the data on Table 1. 

 

 

 

Rhael012
6 - Meteoroid

Hi @apathetichell ,Yes that's right. This is what I'm trying to do. By the way, how can I tag a user in my post? hehe. Sorry, I'm new here.

Labels