I've looked at several posts regarding hierarchy workflows but nothing seems to work for me. I have input that gives employee information including who they report to. I have ranked each position and what I need to do is iterate through the reports to field until I reach someone who is a level 5+ to assign a manager, level 7+ to assign their director, level 8+ for MD, and level 9+ for VP.
Unfortunately, the hierarchy doesn't just step up one time to get to the next level. Some level 1's report to a level 5, some report to another level 1, some managers report to a director and others report straight to an MD.
Below and attached is sample input/output on a very basic level. I'm assuming an iterative macro is the way to go but I'm having difficulty getting it to give me the outputs I want.
Oh and I should mention I'm on Alteryx 2023.2.1.173 Patch 4, as the macro configuration can be different than the newer versions.
INPUT:
| EMP_NM | EMP_ID | REPORTS_TO_NAME | REPORTS_TO_ID | Job Title | Rank |
| Analyst, Name | 001234 | Supervisor, Name | 001236 | Analyst | 1 |
| Analyst, Second | 001237 | Manager, Second | 012347 | Analyst | 1 |
| Team Lead, Name | 001235 | Manager, Name | 012345 | Team Lead | 1 |
| Supervisor, Name | 001236 | Sr Manager, Name | 012346 | Supervisor | 1 |
| Manager, Name | 012345 | MD, Name | 223456 | Manager | 5 |
| Manager, Second | 012347 | Director, Name | 123456 | Manager | 5 |
| Sr Manager, Name | 012346 | Director, Name | 123456 | Sr Manager | 5 |
| Director, Name | 123456 | MD, Name | 212345 | Director | 7 |
| MD, Name | 212345 | VP, Name | 323456 | MD | 8 |
| VP, Name | 323456 | SVP, Name | 423456 | VP | 9 |
| SVP, Name | 423456 | | | SVP | 9 |
OUTPUT:
| EMP_NM | EMP_ID | REPORTS_TO_NAME | REPORTS_TO_ID | Job Title | Rank | Manager | Manager_ID | Director | Director_ID | MD | MD_ID | VP | VP_ID |
| Analyst, Name | 001234 | Supervisor, Name | 001236 | Analyst | 1 | Sr Manager, Name | 012346 | Director, Name | 123456 | MD, Name | 212345 | VP, Name | 323456 |
| Analyst, Second | 001237 | Manager, Second | 012347 | Analyst | 1 | Manager, Second | 012347 | Director, Name | 123456 | MD, Name | 212345 | VP, Name | 323456 |
| Team Lead, Name | 001235 | Manager, Name | 012345 | Team Lead | 1 | Manager, Name | 012345 | MD, Name | 223456 | MD, Name | 223456 | VP, Name | 323456 |
| Supervisor, Name | 001236 | Sr Manager, Name | 012346 | Supervisor | 1 | Sr Manager, Name | 012346 | Director, Name | 123456 | MD, Name | 212345 | VP, Name | 323456 |
| Manager, Name | 012345 | MD, Name | 223456 | Manager | 5 | MD, Name | 223456 | MD, Name | 223456 | MD, Name | 223456 | VP, Name | 323456 |
| Manager, Second | 012347 | Director, Name | 123456 | Manager | 5 | Director, Name | 123456 | Director, Name | 123456 | MD, Name | 223456 | VP, Name | 323456 |
| Sr Manager, Name | 012346 | Director, Name | 123456 | Sr Manager | 5 | Director, Name | 123456 | Director, Name | 123456 | MD, Name | 223456 | VP, Name | 323456 |
| Director, Name | 123456 | MD, Name | 212345 | Director | 7 | MD, Name | 223456 | MD, Name | 223456 | MD, Name | 223456 | VP, Name | 323456 |
| MD, Name | 212345 | VP, Name | 323456 | MD | 8 | VP, Name | 323456 | VP, Name | 323456 | VP, Name | 323456 | VP, Name | 323456 |
| VP, Name | 323456 | SVP, Name | 423456 | VP | 9 | SVP, Name | 423456 | SVP, Name | 423456 | SVP, Name | 423456 | SVP, Name | 423456 |