Hierarchy Lookup

JohnnyGee

New Member
Joined
Apr 4, 2009
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi all...there is probably a straightforward answer to this question though for the life of me I can't work it out myself!

I have a code hierarchy structure. For each code i.e. shown in column B, I want to be able to find the lowest level the code goes to within the hierarchy based on a specific parameter (where Level A is the highest level and Level F is the lowest level)
For example, if I want to find the lowest EP category level for code 3610022, the correct answer would be EP5212 in cell J5.
Another example would be for code 3610089, the lowest level code would be EP2500 in cell H13.

To begin with, I guess I could use an Xlookup to pull through all levels for the codes from the Data Table. The difficult part after that is working out how to pull through the lowest level code where in theory it could be any column between Level A and Level F. I also want it to be flexible where I can search for other lowest level codes i.e. EW, EA etc.

hopefully someone can assist this novice!

1714588399876.png
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
365 seems like a good bet for your version:
MrExcelPlayground22.xlsx
ABCDEFGHIJ
1CodeCodeLevel ALevel BLevel CLevel DLevel ELevel 5
23610010EP51403610010EP1000EP1700EP5000EP5100EP5140
33610022EP52123610022EP1000EP1700EP5000EP5200EP5212MT5212
43610024EP52003610024EP1000EP1700EP5000EP5200
53610037EP50003610037EP1000EP1700EP5000
63610058None Found3610058EA1000EA2000EA3000
Sheet23
Cell Formulas
RangeFormula
B2:B6B2=LET(a,INDEX($D$2:$J$6,XMATCH(A2,$D$2:$D$6,0),),b,FILTER(a,LEFT(a,2)="EP"),c,TAKE(b,1,-1),IFERROR(c,"None Found"))
 
Upvote 0
Thanks so much...the initial signs are very positive. I understand a lot of formulae in terms of what they are doing but I tend to struggle a bit with the syntax!
 
Upvote 0
Having had a bit of a play around with the formula is there a way of adapting it, so for Row 3, say I want to return the lowest level EP or MT level? The formula would recognise both are present but would return J3 as the result as it's the lowest level of the two filter parameters that are in place. I've tried the following but it doesn't work.

=LET(a,INDEX($D$2:$J$6,XMATCH(A2,$D$2:$D$6,0)),b,FILTER(a,LEFT(a,2)="EP")+(LEFTa,2)="MT")),c,TAKE(b,1,-1),IFERROR(c,"None Found"))

1715535013816.png
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

You're missing a couple of brackets, try
Excel Formula:
=LET(a,INDEX($D$2:$J$6,XMATCH(A2,$D$2:$D$6,0),),b,FILTER(a,(LEFT(a,2)="EP")+(LEFT(a,2)="MT")),c,TAKE(b,1,-1),IFERROR(c,"None Found"))
 
Upvote 0
Solution
Another slightly shorter version
Excel Formula:
=LET(a,XLOOKUP(A2,$D$2:$D$6,$E$2:$J$6),TAKE(FILTER(a,(LEFT(a,2)="EP")+(LEFT(a,2)="MT"),"None Found"),,-1))
 
Upvote 0
Another slightly shorter version
Excel Formula:
=LET(a,XLOOKUP(A2,$D$2:$D$6,$E$2:$J$6),TAKE(FILTER(a,(LEFT(a,2)="EP")+(LEFT(a,2)="MT"),"None Found"),,-1))
Perfect...this works a treat. Thanks also for the heads-up on the account update...it had been a very long time between visits to the message board!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top