# Finding / calculating reporting level in organization/hierarchy

#### griffy

##### New Member
So, I have a list exported from a system containing unique employee ids (children). Each of these rows has the employee’s manager unique id (parent). One of the employees is the CEO and is to be considered level = 1

I would like a way to calculate per employee what level they are on in the organization. Is this possible in an effective way?

Have tried a solution I found before based on MATCH and INDEX, but it is cumbersome and seems to consume enormous resources to calculate and recalculated all the time.

 Unique child id Unique parent id level 1 88 ? 2 99 ? 3 44 ? 4 55 ?

<tbody>
</tbody>

### Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

#### Michael M

##### Well-known Member
You haven't shown us how you arrive at the calculated level for each employee and what criteria is required to do the calculation.
You might be better providing a sample of data with the end result already shown and how you arrived at that result.

#### griffy

##### New Member
the formula i have used and that finally actually give the desired outcome is; =IF(A2=1;1;1+INDEX(C:C;MATCH(B2;A:A;0))) the issue is that its heavy and there are ~45k rows in up to 15 levels.
CEO is set to ID = 1

#### Michael M

##### Well-known Member
Have you tried reducing your INDEX/MATCH ranges.....
You say approx 45000 rows, so change the formula to
Code:
``=IF(A2=1;1;INDEX(C1:C50000;MATCH(B2;A1:A50000;0))+1)``

#### griffy

##### New Member
I used this instead, that worked =IF(A2=1;1;1+INDEX(\$C\$1:\$C\$45000;MATCH(B2;\$A\$1:\$A\$45000;0)))
i did however get 2k rows that got level zero
could this be don in a query ?

Threads
1,089,560
Messages
5,408,981
Members
403,247
Latest member
prabutr28

### This Week's Hot Topics

• help please
SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
• two formulas needed
Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
• Dynamic Counts
Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
• Help Excel formula eliminate duplicate values and keep only 2 identical rows.
as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
• Macro Compile Error Sub or Function not defined
Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
• Last row combined with Current Region VBA
I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...