+ Reply to Thread
Results 1 to 15 of 15

Tree Network

  1. #1
    Registered User
    Join Date
    09-16-2014
    Location
    London
    MS-Off Ver
    2010 (In 2024)
    Posts
    24

    Tree Network

    Hi,
    I design gas networks and I am looking into incorporating our design calculator (an old DOS program) into Excel but it is beyond my skills.

    I have attached a spreadsheet that shows a 'tree' network that I draw in AutoCAD. I then have a routine that exports all of the pipes from AutoCAD to Excel (columns A-C in the attached spreadsheet).

    I am trying to extract every possible route from the first number (1) to each extremity. The possible scenarios are shown in columns E-G, I-K, M-O & Q-S. This is a small example and could end up being hundreds of pipes.

    I would really appreciate if someone could help with this or at least tell me if it is possible in Excel!

    Many thanks,

    Andy
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,992

    Re: Tree Network

    Administrative Note:

    Members will tailor the solutions they offer to the version (NOT release number) of Office (Excel, NOT Windows) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your version is for Mac, please also state this. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Tree Network

    If you don't mind to use a lot of helper cells.

    1. Count how many possible route
    E5
    =COUNTIF($A$5:$A$10,B5)
    F4
    =COUNTIF($E$5:$E$10,0)

    2. Create route from the last to the first.
    H5
    =IF($G5<=$F$4,INDEX($B$5:$B$10,AGGREGATE(15,6,(ROW($E$5:$E$10)-ROW($E$4))/($E$5:$E$10=0),$G5)),"")
    I5 (copy to right as much of your longest route noeds)
    =IF($G5<=$F$4,IFERROR(INDEX($A$5:$A$10,MATCH(H5,$B$5:$B$10,0)),""),"")

    3. Summary route
    H16 (first element of each route)
    =IFERROR(AGGREGATE(15,6,OFFSET($G$4,$F16,1,1,COLUMNS($H$4:$Q$4)),$G16),"")
    the others formula is just sumifs

    Note: In the result , it will repeated last node without connected node and length.

    Regards.
    Attached Files Attached Files
    Last edited by menem; 05-20-2022 at 05:25 AM. Reason: Edit file/formula.

  4. #4
    Registered User
    Join Date
    09-16-2014
    Location
    London
    MS-Off Ver
    2010 (In 2024)
    Posts
    24

    Re: Tree Network

    Hi,

    Thank you for this that looks amazing! I will have a go at incorporating into my spreadsheet and let you know if I have any issues.

    One question I have is regarding the following formula: =IF($G5<=$F$4,INDEX($B$5:$B$100,AGGREGATE(15,7,(ROW($E$5:$E$100)-ROW($E$4))/($E$5:$E$100=0),$G5)),"")

    What does the 15,7 refer to?

  5. #5
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Tree Network

    It's not 15,7 , it's 15,6

    15 is refer to function number 15 (small value)
    6 is options , 6 = ignore error values.

    Regards.

  6. #6
    Registered User
    Join Date
    09-16-2014
    Location
    London
    MS-Off Ver
    2010 (In 2024)
    Posts
    24

    Re: Tree Network

    Hi,

    I have incorporated your spreadsheet into mine and it works great, thanks!
    There is one issue that I have come across and that is we can sometimes have backwards nodes (see example). Can you think of a way around this? As you will see the data on sheet 1 always lists the highest node number in the second column. If this is getting too complex then please let me know!
    Attached Files Attached Files

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,992

    Re: Tree Network

    Are you still using Excel 2010?

  8. #8
    Registered User
    Join Date
    09-16-2014
    Location
    London
    MS-Off Ver
    2010 (In 2024)
    Posts
    24

    Re: Tree Network

    Hi, yes I am.
    Last edited by AliGW; 05-25-2022 at 05:48 AM. Reason: PLEASE don't quote unnecessarily!

  9. #9
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Tree Network

    I can't find out the formula that can be use in every cells.
    I need to modify each formula in each column.

    like....
    in the column I (the 1st of next_previous value) formula will be.
    =IF($G5<=$F$4,IFERROR(INDEX($A$5:$A$11,AGGREGATE(15,6,(ROW($B$5:$B$11)-ROW($B$4))/(1/($B$5:$B$11=H5)),COUNTIFS($H$4:$H5,$H5))),""),"")

    then in column J (the 2nd of next_previous value).
    =IF($G5<=$F$4,IFERROR(INDEX($A$5:$A$11,AGGREGATE(15,6,(ROW($B$5:$B$11)-ROW($B$4))/(1/($B$5:$B$11=I5)),COUNTIFS($H$4:$H5,$H5,$I$4:$I5,$I5))),""),"")

    the next will be (K)
    =IF($G5<=$F$4,IFERROR(INDEX($A$5:$A$11,AGGREGATE(15,6,(ROW($B$5:$B$11)-ROW($B$4))/(1/($B$5:$B$11=J5)),COUNTIFS($H$4:$H5,$H5,$I$4:$I5,$I5,$J$4:$J5,$J5))),""),"")

    Regards.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-16-2014
    Location
    London
    MS-Off Ver
    2010 (In 2024)
    Posts
    24

    Re: Tree Network

    Hi, thank you for your help, I really appreciate it!
    Unfortunately it doesn't appear as if all of the routes are working on the new example and I think it is the backwards node 10 that is the reason.
    I have a attached a new spreadsheet that shows the required routes on Sheet 1 (columns E-S).
    Is this possible?
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Tree Network

    Please review in sheet3 (I've copy above formula into sheet3).
    And may I ask, should 5-10, 6-10, 7-10 should be separated from the previouse route ?

    Capture.JPG

    Regards.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    09-16-2014
    Location
    London
    MS-Off Ver
    2010 (In 2024)
    Posts
    24

    Re: Tree Network

    The routine needs to show every possible route from node 1 (the 1st node) to each extremity so nodes 5-10, 6-10 & 7-10 don't need to be separated.
    The routes I need to show on the image from sheet 1 would be:
    Node 1-2-3
    Node 1-2-10-5
    Node 1-2-10-6
    Node 1-2-10-7

    Your original formula works great for nodes that run in sequence but it doesn't seem to like it when the nodes don't run in numerical order.

    If this is too complex I can just try to ensure that the nodes always run in sequence but I wanted to try and cover every scenario.


    I hope this makes sense!

  13. #13
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Tree Network

    Edited, swap manually can't solved problem.

    In that case, could the data swap as in a picture ?

    Capture.JPG

    If yes, the old formula will be worked.

    Regards.
    Last edited by menem; 05-26-2022 at 05:32 AM. Reason: Edit , error found.

  14. #14
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Tree Network

    If you can't swap it manually.
    You may use swapper area ( as in Sheet2 (2) )

    NodeFrom
    =IF(F5=B5,A5,B5)

    NodeTo
    =IF(A5<>1,IF(COUNTIF($A$5:$B$10,A5)=1,A5,B5),B5)

    And in result area will be need to change formula to
    L16
    Please Login or Register  to view this content.
    Regards.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    09-16-2014
    Location
    London
    MS-Off Ver
    2010 (In 2024)
    Posts
    24

    Re: Tree Network

    Thank you so much for your help. I will have a play around with the new formula and see how I get on!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Dependency Tree
    By m1n1m3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-28-2019, 01:06 PM
  2. [SOLVED] Vba to copy a file from a network path and place it to another network path location
    By ROHAN999 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-12-2018, 01:09 PM
  3. [SOLVED] Transforming 1level coded product tree to few level product tree
    By Gukupozu in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-07-2015, 10:31 AM
  4. Decision Tree
    By Slosher in forum Excel General
    Replies: 2
    Last Post: 08-29-2014, 09:58 AM
  5. topology network tree
    By koi in forum Excel General
    Replies: 0
    Last Post: 12-16-2010, 09:29 AM
  6. Tree Structure
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-24-2005, 11:06 PM
  7. [SOLVED] VB Tree View
    By samycbe in forum Excel General
    Replies: 1
    Last Post: 02-23-2005, 12:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1