Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Unique tool without excluding dupliactes

DanMax
6 - Meteoroid

Hey guys, 

 

I am matching a set of case firms with a set of control firms based on industry classification and asset size. I want to match each case firm with the closest control firm in terms of asset size (within an industry). However, I want to make sure, that each control firm is only included once. The problem is, that if I sort by Asset Difference and then apply the Unique tool to filter for unique control firms, I eliminate all the other possible combinations for the second case firm.

 

In the event of two case firms leading to the same control firm, I want the second case firm two go for the second closest control firm in terms of asset size. Please see the Example below. The best match for Firm ABC and Firm XYZ would be Firm E. (closet asset difference). As the same control firm can not be included twice, Firm XYZ should go for the second closest control firm, which is in this example Firm D. 

 

 

Input

Case FirmTotal AssetsIndustry
Firm ABC1001
Firm XYZ10001

 

Control FirmsTotal AssetsIndustry
Firm D18001
Firm E11001
Firm F20001

 

Match

Case FirmControl FirmAsset Difference (absolute)Industry
Firm ABCFirm D17001
Firm ABCFirm E10001
Firm ABCFirm F19001
Firm XYZFirm D8001
Firm XYZFirm E1001
Firm XYZFirm F10001

 

Wanted Output 

Case FirmControl FirmAsset Difference (absolute)Industry
Firm ABCFirm E10001
Firm XYZFirm D8001

 

Do you have any idea how to implement this on Alteryx? 

 

Thank you very much and have a nice day

 

 

13 REPLIES 13
AngelosPachis
16 - Nebula

Hi @DanMax ,

 

I consider that to be possible in all workflows but each one of them will have a different tweak. The key here would not be to make all of them work of course, but understand more or less how they work as you might need that knowledge going forward.

 

In the workflow I have attached in my previous post, all you need to do is open the iterative macro and change the sort tool so you only sort on the Difference field and then save the new iterative macro.

 

AngelosPachis_0-1621971775633.png

 

That will match XYZ with E and in the next run ABC will match with D.

 

Hope that makes sense in a way, let me know if there are any questions.

 

Cheers,

 

Angelos

mceleavey
17 - Castor
17 - Castor

@DanMax ,

 

I've attached the new macro using the difference to drive the first selection.

 

This gives the following:

 

mceleavey_0-1621972112238.png

 

Let me know if this is correct.

 

M.



Bulien

DanMax
6 - Meteoroid

Thanks guys, I will look into this and let you know asap. 

DanMax
6 - Meteoroid

Thanks a lot guys, it works perfectly! 

Labels