Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Flattening data from three left joined tables

leahpenelope
7 - Meteor

Hi everyone,

 

I have three tables - R,S,T - which were combined using two left joins in SQL.

Table R was joined with Table S in a left join followed by Table R was joined with Table T in a left join, in one SQL query.

Let's called the resulting table, Table Z.

 

Table R has one common field R-S with S.

Table R has one common field R-T with T.

Tables S and T have no common fields.

 

Moreover, one other field in Table R - field M - tends to have duplicate values - one pointing to Table S and one pointing to Table T.

 

For e.g. if I were to group by field M in Table Z using the Summarize tool in Alteryx, I will see at least two rows of the same value in field M. The top row will have values in the fields from Table S and null values in the fields from Table T, and the bottom row will have values in the fields from Table T and null values in the fields from Table S.

 

I wish to 'flatten' these rows with duplicates of M without losing data from Tables S or T.

As Table T has more rows than Table S, likely Table S will take on null rows. See graphical illustration of the desired transformation.

 

Can someone help me brainstorm the best way to go about flattening the data?

 

Thank you

2 REPLIES 2
echuong1
Alteryx Alumni (Retired)

It sounds like this can be accomplished with Joins and the Summarize tool.

 

Are you able to upload some sample data for each of your tables, as well as your goal output?

leahpenelope
7 - Meteor

Hello @echuong1 

Thanks for your tip.

I was able to solve using the Summarize tool.

Group by "R-M field" and Max each of "S-Name", "S-Value, "T-Name", "T-Value"

That would flatten the table.

 

Currently:

 

R-M fieldS-NameS-ValueT-NameT-Value
1Alice3nullnull
1nullnullTim4
2Sharon8nullnull
2nullnullBob2
3Lisa6nullnull
3nullnullRyan1
4nullnullChris3
5Amy2nullnull
5nullnullRichard4
6nullnullMike5

 

Goal:

 

R-M fieldS-NameS-ValueT-NameT-Value
1Alice3Tim4
2Sharon8Bob2
3Lisa6Ryan1
4nullnullChris3
5Amy2Richard4
6nullnullMike5
Labels