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 ,

 

What if instead of a unique tool you use a sample tool to keep the first record per Case Firm? Would that work?

 

AngelosPachis_0-1621966237086.png

 

EDIT : Scratch that, missed the "each control firm is included once" bit

 

Luke_C
17 - Castor
17 - Castor

@AngelosPachis I was going this route as well, but the complexity lies in the requirement that for the 2nd record, the control firm can't be used for multiple case firms. I'm thinking perhaps an iterative macro could be leveraged to remove the first control firm from the set, then re-apply the sample logic you have. 

AngelosPachis
16 - Nebula

Yes @Luke_C you are right, I missed it when I first read the post. Trying to think of a logic to avoid the iterative macro but not sure I can come up with something

DanMax
6 - Meteoroid

Yeah, that makes sense. A macro that would remove the first combination of Firm ABC - Firm E. So that only Firm D and F can be matched to Firm XYZ. 

Luke_C
17 - Castor
17 - Castor

@DanMax 

 

Take a look at this. The macro will use @AngelosPachis 's logic of sorting and sampling, but then I use join tools to remove the already processed case firm and control firm. The remaining data is passed through again to be sorted and sampled. 

 

Luke_C_0-1621967295882.png

 

Luke_C_1-1621967316781.png

 

 

 

mceleavey
17 - Castor
17 - Castor

Hi @DanMax 

 

I've built an iterative macro to do this and it produces the following:

 

mceleavey_0-1621967814753.png

 

The workflow appends the records together and feeds into the macro:

 

mceleavey_1-1621967840374.png

 

and the macro looks like this:

 

mceleavey_2-1621967872520.png

 

I've attached the package, the workflow and the macro.

 

Hope this helps.

 

M.

 



Bulien

AngelosPachis
16 - Nebula

@DanMax 

 

Late to the party with another iterative one - looks similar to what @Luke_C has done I think

 

AngelosPachis_0-1621968376714.png

 

Output

AngelosPachis_1-1621968403982.png

 

 

DanMax
6 - Meteoroid

Hey guys,

 

Thank you very much for your support. Really appreciate your effort. 

I have just figured out a mistake in my instructions. As the asset difference between Firm XYZ and Firm E (100) is smaller then Firm ABC and Firm E (1000), I want that Firm E is matched to Firm XYZ. So basically the iterative process should start from the smallest difference available. Consequently Firm ABC should be matched to D. Does that make sense and is it possible to implement that? 

 

mceleavey
17 - Castor
17 - Castor

Hi @DanMax ,

 

you can just change the calculation in my iterative macro. (right click, open macro)

Currently, it's just assigning the lowest Control Firm total assets. Create the difference calculation and select the lowest of that instead.

 

M



Bulien

Labels