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 Firm | Total Assets | Industry |
| Firm ABC | 100 | 1 |
| Firm XYZ | 1000 | 1 |
| Control Firms | Total Assets | Industry |
| Firm D | 1800 | 1 |
| Firm E | 1100 | 1 |
| Firm F | 2000 | 1 |
Match
| Case Firm | Control Firm | Asset Difference (absolute) | Industry |
| Firm ABC | Firm D | 1700 | 1 |
| Firm ABC | Firm E | 1000 | 1 |
| Firm ABC | Firm F | 1900 | 1 |
| Firm XYZ | Firm D | 800 | 1 |
| Firm XYZ | Firm E | 100 | 1 |
| Firm XYZ | Firm F | 1000 | 1 |
Wanted Output
| Case Firm | Control Firm | Asset Difference (absolute) | Industry |
| Firm ABC | Firm E | 1000 | 1 |
| Firm XYZ | Firm D | 800 | 1 |
Do you have any idea how to implement this on Alteryx?
Thank you very much and have a nice day