Traversing a hierarchy with VLOOKUP - excel-formula

I have the following dataset:
ID Name Level DirectBoss
E1 MegaBoss 1
E2 SuperBoss1 2 E1
E3 SuperBoss2 2 E1
E4 RegularBoss1 3 E2
E5 RegularBoss2 3 E2
E6 RegularBoss3 3 E1
E7 John 4 E5
E8 Mary 4 E6
It defines a pretty conventional hierarchy: a bunch of employees identified by an ID, their name, which level they are placed in the hierarchy, and who is their direct boss.
My problem is that I need to find out who's the boss of a particular employee, but at an specific level. In this example, John's level 1 boss is MegaBoss, level 2 is SuperBoss1, and level 3 would be its direct boss, RegularBoss2.
How could I calculate this with a formula? It looks like a job for some kind of recursive VLOOKUP: I would look for John's direct boss, then for his boss's boss, and stop when I've got to the desired level. But of course conventional VLOOKUP doesn't work this way. Is there some way to achieve this result?
Thanks!

Related

Matching cell from two values

need help here :) I am not excel expert
I have a simple spread sheet with some data and I need to find the matching values from another sheet. Some help would be appreciated.
The data looks like this:
d1 d2 d3 d4 d5
c1 1 5 4 4 3
c2 2 4 9 1 2
c3 4 4 7 8 4
c4 4 7 1 9 2
c5 4 4 7 6 8
So above c1, c2 etc. means Code's and d1, d2 etc. means Dates (future dates).
The numbers between I need to catch in a different spread sheet
example
Code: c2 - User provides the code
Date: d4 - User provides the date
Value: 1 - this value I need to get with formula
Should I attach example file if needed?
If possible to use performance wise formulas as might be quite few of them. Perhaps INDEX/MATCH? if I know how to use it :) but I think also INDEX/MATCH will slow it down a lot, I might be wrong also :)
thank you for your help in advance.
EDIT:
Added screenshot, might help also what is needed.
Assumptions / prerequisites:
Sheet1 cells (A1:F6) is your data / headers from your example
Sheet2 cell B3 is where the user types the code
Sheet2 cell B4 is where they type the date
Sheet2 cell B5 is where the value displays
this would be your formula in Sheet2 C5
=INDEX(Sheet1!A:F,MATCH(B3,Sheet1!$A:$A,0),MATCH(B4,Sheet1!1:1,0))

Sum Multiple values in different Rows using Vlookup Function

A B
France 152
Italy 255
France 221
Spain 215
USA 222
Spain 155
I desire to add each value occurring in front of repeating countries using Vlookup function
Solution:
A B
France 373
Spain 370
If you use a SUMIF then you can total the columns
If the data starts in cell A1 then in cell C2 type
=SUMIF(A:A,A3,B:B)
then drag the formula down. this will give totals for each country
Or if you just want to show the first instance (where it says France for example) then use
=IF(COUNTIF(A$1:A2,A2)=1,SUMIF(A:A,A2,B:B),"")
You won't be able to do it with a vlookup.
You could use a pivot table which might be easier and that is useful for this exact type of question.
To get the list of repeating countries enter the following formula in Cell D2
=IFERROR(INDEX($A$2:$A$7,MATCH(1,INDEX((COUNTIF($D$1:D1,$A$2:$A$7)=0)*(COUNTIF($A$2:$A$7,$A$2:$A$7)>1),0,0),0)),"")
Then to get sum of corresponding country, in Cell E2 enter
=SUMIF($A$2:$A$7,D2,$B$2:$B$7)
Drag/Copy formulas as required. See image for reference.

Multiple What IF Statement in Excel for Soccer score project

I have a long list of soccer data but in it's most simplistic form it looks like this:
A1 Barcelona
A2 Madrid
A3 2
A4 1
A5 (this will be the IF Statement)
There are over 200 rows but all with the same premice, so what I want is an if statement that says if the score in A3 is larger than A4 then A5 has a W and if A4 is a larger score than A3 than A5 has an L
Can someone give me some pointers as to how to do this, only need to know it for the top line of the data and then I can replicate throughout
Thanks
Dan
Try this if statement:
=IF(A3>A4,"W",IF(A4>A3,"L",IF(A3=A4,"Tie","")))

Replace a number with text from a table

I have to pull account reports out of a system but the regions are represented as a number. I have a separate list that has two columns, one with the region name and one with the corresponding number. I'm looking to write a formula that identifies the number in the report column and populates it with the region name from my static table.
Example:
Region List
A1 B1
1 00 London
2 01 West Midlands
3 02 Greater Manchester
Report
A2 B2
1 Customer A 00
2 Customer B 02
3 Customer C 02
4 Customer D 01
5 Customer E 00
As mentioned, I want to populate column B2 with the data from B1. B2's numbers will corrispond with A1's numbers. It's worth mentioning that there are also some variations like 07D or 19H, so the formula would need to take that into account.
Use this function, I hope it will work.
=INDEX('Region List'!$B$1:$B$3;MATCH($B1;'Region List'!$A$1:$A$3;0))

Excel formula checking multiple conditions

I am creating a grading sheet for my students in excel, but I am stuck on a complex formula. I am trying to create a formula that will do this:
If(Cells A1 AND B1 AND C1 >= 24)AND(Cells D1 AND E1 AND F1 AND G1 AND H1 >=120 and <174)
Then Print "Level 2 PP"
Else IF (Cells A1 AND B1 AND C1 >= 24)AND(Cells D1 AND E1 AND F1 AND G1 AND H1 >=150 and <204)
Then Print "Level 2 MP"
Else If(Cells A1 AND B1 AND C1 < 24)AND(Cells D1 AND E1 AND F1 AND G1 AND H1 >=120 and <174)
Then Print "Level 1 Pass"
I hope this gives an idea of what I am trying to achieve. It's very hard to understand as the students have to achieve a certain amount of points in certain units to achieve certain grades. Any help will be greatly appreciated.
Generally, the way to do what you want to accomplish is with Nested If statements.
Before getting to that, the conditions you list in your question could be constructed like this:
IF(AND(MIN(A1:C1)>=24,MIN(D1:H1)>=120,MAX(D1:H1)<174),"Level 2 PP",
"Not Level 2 PP")
IF(AND(MIN(A1:C1)>=24,MIN(D1:H1)>=150,MAX(D1:H1)<204),"Level 2
MP","Not Level 2 MP")
IF(AND(MIN(A1:C1)<24,MIN(D1:H1)>=120,MAX(D1:H1)<174),"Level 1
Pass","Not Level 1 Pass")
Putting these together, I get:
=IF(AND(MIN(A1:C1)>=24,MIN(D1:H1)>=150,MAX(D1:H1)<204),"Level 2
MP",IF(AND(MIN(A1:C1)>=24,MIN(D1:H1)>=120,MAX(D1:H1)<174),"Level 2
PP",IF(AND(MIN(A1:C1)<24,MIN(D1:H1)>=120,MAX(D1:H1)<174),"Level 1
Pass","Other")))
The criteria for "Level 2 MP" overlaps with "Level 2 PP." I made the "Level 2 MP" the "outside of the nest," so, in the case of overlap, student will be identified as Level 2 MP.
I strongly suspect the categories you are interested in aren't exactly as you described them. For one thing, as noted above, they overlap. And, assuming a bigger number is better, does a student really not "Level 1 pass" if one of A1, B1 or C1 are > 24?
If there are more categories, or if the criteria are more complicated, I'd consider using separate columns to do some of the intermediate calculations. Hope this helps.

Resources