Alteryx Designer Desktop Discussions

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

Join with same dataset but get details from the right as well

shravanvijayaprasad
8 - Asteroid

Hi all, I have a simple example input

 

YearCountryAmount
2015US90
2015Canada95
2016US100
2016Canada105
2017US110

 

 

I want to get the prior year amount as another column, when I do a join I can get 

YearCountryAmountPY Amount
2015US900
2015Canada950
2016US10090
2016Canada10595
2017US110

100

 

But I want to get

YearCountryAmountPY Amount
2015US900
2015Canada950
2016US10090
2016Canada10595
2017US110100
2017Canada0105

 

The last line 2017 - Canada isn't showing up if I do a join. Can someone help me with this?

6 REPLIES 6
fmvizcaino
17 - Castor
17 - Castor

Hi @shravanvijayaprasad ,

 

Attached is an example showing how to do it. I needed to add a few more tools to automatically remove future years (in your dataset it would be 2018)

 

fmvizcaino_0-1581386760633.png

 

LEt me know if this works for you.

Best,

Fernando Vizcaino

BrandonB
Alteryx
Alteryx

@fmvizcaino I think that a multi row tool could probably take care of this as well doing a group by country

shravanvijayaprasad
8 - Asteroid

could you let me know how?

fmvizcaino
17 - Castor
17 - Castor

Hi @BrandonB ,

 

You would still need to create first a new row for 2017 Canada, but yes, that is another way to tackle the problem! 

 

Best,

Fernando Vizcaino

BrandonB
Alteryx
Alteryx

Similar concept but slightly different approach. If every row existed including 2017 Canada then it would be as easy as just using a multi row tool. Because this is not the case, I created every combination of year/country, found which ones did not exist in the data set because they fell out of the right side of the join. Then assigned a zero placeholder for the amount. Finally, once every year and country combo was in the data set, we can then use the multi row tool to pull the value from the previous row within the country group and finally sort. 

 

My approach.png

shravanvijayaprasad
8 - Asteroid

This solution is nice too! thanks! 

Labels