If I've understood, that's a big IF here, the below might work for you:
Key assumption is that you're interested only in the deficits such that there is no concept of getting credit for being over-skilled.
To that end, the multitude of H* tests in the LOOKUP are technically redundant, a single H test would suffice - but have left in as easier to follow, and adapt as nec.
Ranges can be modified to accommodate your real data etc.
The above would generate following output based on your sample data:
2, 3, 2
2, 1, 4
2, 2, 1
5, 6, 5
5, 5, 6
1, 2, 1
If the above is incorrect, quite likely, post another sample with expected results for each intersection -- much easier to follow requisite logic with multiple outputs.
Bookmarks