Employee Hierarch query

mart_mrexcel

Active Member
Joined
Aug 23, 2008
Messages
295
Office Version
  1. 365
Platform
  1. Windows
I have a database hierachy where an employee is reporting to a Manager, i wanted get the value (Emp ID) of the employee's LAST Manager in the hierarchy.

In the example, Employee 1022 is reporting to Emp 4901 with "Manager" or "Mgr" in the position, however, the 2nd line manager of emp 1022 (i.e. the manager of emp 4901) is reporting to emp 4693 where it has "Manager" or "Mgr" in the position title also. Given this, the expected value of employee's LAST manager is Emp 4693. Basically, i want to get the emp id of the employee's Last manager in the hierarchy with "Manager" or "Mgr" position in the title.

Book1
ABCDEFGH
1
2DatabaseHierarchy
3Emp IDCURRENT Position TitleMgr's IDEmp IDMgr's IDMgr's PositionWith "Manager" or "Mgr" in position?
41022Specialist III, Process Training490110224901Manager, PP1
54693Senior Manager, Polymer Operations523649014693Senior Manager, Polymer Operations8
64901Manager, PP469346935236GM, Manufacturing 
77819VP - ManufacturingNO_MANAGER52367819VP - Manufacturing 
810737VP, Downstream7819
913655Managing Director, Cristal Int. Hold. BV204751
1016573Manager, Debt Management208855Expected Output4693
1119491Sr Specialist I, EBS Function Bus Solution204158
125236GM, Manufacturing7819
Sheet1
Cell Formulas
RangeFormula
F4:F7F4=XLOOKUP(E4,$A:$A,$C:$C)
G4:G7G4=XLOOKUP(F4,$A:$A,$B:$B)
H4:H7H4=IFERROR(SEARCH(@{"Manager","Mgr"},TRIM(G4),1),"")
Named Ranges
NameRefers ToCells
_FilterDatabase=Sheet1!$A$3:$G$3302F4:G7
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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