Forum Discussion

Nic Walmsley's avatar
Nic Walmsley
Copper Contributor
Aug 03, 2018

Help with tricky formulas

Hi there,

 

I need some help with some tricky excel formulas. Would greatly appreciate some help as I have nearly 7000 rows of data to sort out. The developer I was hoping to get help from has handed back to me and it's beyond what I can do.

 

The first 2 columns below are example of my source data. I need to populate the next 3 columns with formulas. I've populated some of them manually to help explain.

 

The 3rd column is easy, a copy of the 1st column. Lets call these the NODE values.

 

The 4th column is the PARENT of the node. To find the parent, I need to look into column 2, the node level. Lets say the node I'm looking at is from level 3. The parent of this node will be the first level 2 node that occurs above it in the list. For example, 1NTH is a level 3 node, and the first level 2 node that occurs above it is SP1 - making SP1 the parent of 1NTH.

 

The 5th column is the PROCEEDING node from the same level. Similar to above, I need to look at the node immediately above the current node, and if it is from the same level as the current node, it is deemed the "proceeding node". Otherwise this cell is blank.

 

I sure hope I have explained this sufficiently, and thanks to anyone who tries to sort this one out!

 

Site ValueLevelNodeParent (the first node with a lower level value above it, blank if none)Prior Node (= the node immediately above it, if they have the same level - otherwise blank)
HOMEN1HOMEN  
SP12SP1HOMEN 
1NTH31NTHSP1 
1NTHMAN41NTHMAN1NTH 
1NTHMAN02451NTHMAN0241NTHMAN 
1NTHMAN02751NTHMAN0271NTHMAN1NTHMAN024
1110270641611102706411NTHMAN027 
1NTHMAN02851NTHMAN0281NTHMAN 
1110280641611102806411NTHMAN028 
1NTHMAN02951NTHMAN0291NTHMAN 
1NTHMAN03651NTHMAN0361NTHMAN1NTHMAN029
1110360641611103606411NTHMAN036 
111036064261110360642????????
111036083161110360831????????
111036160561110361605????????
1NTHMAN03851NTHMAN038????????
111038064161110380641????????
111038064261110380642????????
1NTHMAN04351NTHMAN043????????
111043064161110430641????????
1NTHMAN04551NTHMAN045????????
1NTHMAN04751NTHMAN047????????
1NTHMAN04851NTHMAN048????????
1NTHMAN04951NTHMAN049????????
1NTHMAN05061NTHMAN050????????
1NTHMAN05151NTHMAN051????????
1NTHMAN05261NTHMAN052????????
1NTHMAN05361NTHMAN053????????
1NTHMAN05461NTHMAN054????????
1NTHMAN05561NTHMAN055????????
1NTHMAN05661NTHMAN056????????
1NTHMAN05761NTHMAN057????????
1NTHMAN05851NTHMAN058????????
1NTHMAN05951NTHMAN059????????
1NTHMAN06051NTHMAN060????????
1NTHMAN06161NTHMAN061????????
1NTHMAN06261NTHMAN062????????
1NTHMAN06351NTHMAN063????????
1NTHMAN06451NTHMAN064????????
1NTHMAN06551NTHMAN065????????
1NTHMAN06651NTHMAN066????????
1NTHMAN06751NTHMAN067????????
1NTHMAN06851NTHMAN068????????
1NTHMAN06951NTHMAN069????????
1NTHMAN07051NTHMAN070????????
1NTHMAN07151NTHMAN071????????
1NTHMAN07261NTHMAN072????????
1NTHMAN07361NTHMAN073????????
1NTHMAN07451NTHMAN074????????
1NTHMAN07551NTHMAN075????????
1NTHMAN07661NTHMAN076????????
1NTHMAN07761NTHMAN077????????
1NTHMAN07851NTHMAN078????????
1NTHMAN07951NTHMAN079????????
1NTHMAN08061NTHMAN080????????
1NTHMAN08151NTHMAN081????????
1NTHMAN08251NTHMAN082????????
1NTHMAN08351NTHMAN083????????
1NTHMAN08441NTHMAN084????????
1NTHMAN08551NTHMAN085????????
etcetcetcetcetc
  • Hi Nic,

     

    It could be for the row #2

     

    Column C

    =A2

    Column B

    =IFERROR(LOOKUP(2,1/(($B2-1)=$B$2:$B2),$A$2:$A2),"")

    Column D

    =IF($B2=$B1,$C1,"")

    and drag them down. Attached.

    • Nic Walmsley's avatar
      Nic Walmsley
      Copper Contributor

      Thank you Sergei, that is much appreciated.

       

      Your answer has helped me realize I mischaracterized the rule for Column D. I tried to rework the answer you gave for Column C (which has worked perfectly) - but couldn't get it right. Coming back here for more help is the most sensible thing to do. Hope you don't mind!

       

      The rule for D is more like this

       

      Look up at all the values above and find the next node with the same level, BUT if you encounter a node with a lower level number first, leave the cell blank.

       

      So if the row I'm on is for a node at level 3, it would look up and find the next node from level 3 (looking upwards from my row towards the top). But if it hit a node from level 2 (or 1) before it found a another 3, it would leave it blank.

       

      D could be characterized as "proceeding sibling"

       

      Here's a new example if that helps:

       

      NodeLevelParentProceeding Sibling
      Food1  
      Friut2Food 
      Apple3Fruit 
      Orange3FruitApple
      Banana3FruitOrange
      Grape3FruitBanana
      Red Grape4Grape 
      Green Grape4GrapeRed Grape
      Meat2FoodFruit
      Beef3Meat 
      Chicken3MeatBeef
      Lamb3MeatChicken
      Fish3MeatLamb
      Snapper4Fish 
      Cod4FishSnapper
      Desert2FoodMeat
      Veges2FoodDesert
      Potatoe3Veges 
      Carrot3VegesPotatoe

       

      Once again, thank you for the help. Can't say how nice it is to find part of the internet that is friendly and helpful!

       

       

  • pranav trikha's avatar
    pranav trikha
    Brass Contributor

    Greetings!

    As understood, please find formula

    for 4th column:=IF(AND(B3>B2,C2<>""),CELL("contents",C2),"")

    for 5th column:=IF(AND(B3=B2,C2<>""),CELL("contents",C2),"")

    Thanks,

Resources