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

How to get latest replacement product when there are multiple replacements?

RBF
7 - Meteor

Hi

 

I have data in this format.  It tells me what the product code is and what new code has replaced that product:

 

ProductReplaced By
10000011000003
10000021000004
10000031000005
10000041000010
10000051000007
10000061000008
10000071000008
1000008 
10000091000011
1000010 
1000011 

 

As you can see sometimes a product is replaced many times e.g. 1000001 is replaced by 1000003 which is replaced by 1000005, and so on until we get to the last product 1000008 which has no replacement.

 

Alas, the numbers do not always increase with each step (normally they do but I have a tiny % where the replacement code is a lower  lower number than the original). 

 

What I want to get is a result that tells me what the very, very last replacement is in the chain, like this:

ProductReplaced ByFinal Replacement
100000110000031000008
100000210000041000010
100000310000051000008
100000410000101000010
100000510000071000008
100000610000081000008
100000710000081000008
1000008  
100000910000111000011
1000010  
1000011  

 

How could I do this in the desktop designer?

4 REPLIES 4
Qiu
21 - Polaris
21 - Polaris

@RBF 
It comes to me that your question is actually a question of building hierarchy.

We can borrow the Hierarchy Generation macro here and make a flow as below

https://community.alteryx.com/t5/Engine-Works/Building-a-Hierarchy-With-Kevin-Bacon/ba-p/453715

0930-RBF.png

RBF
7 - Meteor

I will try it!

RBF
7 - Meteor

Hi!  Okay this is brilliant and absolutely works with clean data!  

 

But... what if you have bad data and it makes a loop?  How can I make it give an error or add some sort of cycle breaking?

 

For example, if 1000008 was replaced by 1000006 but 1000006 says that its replaced by 1000008?

ChrisTX
16 - Nebula
16 - Nebula

The attached workflow uses the Make Group tool to identify the relationships between [Product] and [Replaced By].

 

Screenshot 2024-09-30 075720.png

 

Chris

Labels
Top Solution Authors