[Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register]

Author Message
cmclaren1978
Newbie

Joined: 02 Jul 2012
Posts: 4

 Posted: Fri Jul 13, 2012 12:18 am    Post subject: Possible VLOOKUP formula with two items of dependant data? Hi all I have a list of places, with distances between them all, for example: Column A - Column B - Column C A-B 4km A-C 6km A-D 8km B-C 3km B-D 5km C-D 1km . . and so on (there are about 20 different locations) This is sat on a separate tab (Runs), and my working spreadsheet is called (Route) I need to try and find the quickest route - so trying to plan it using Calc - is there a way of saying if I wanted to go A-C-D-B, and listed that on my Route spreadsheet, I could use a VLOOKUP formula to show the distance? Alternatively, can anyone think of a workaround - possibly using CONCATENATE to show the data as one cell? Thanks
Robert Tucker
Moderator

Joined: 16 Aug 2004
Posts: 3367
Location: Manchester UK

 Posted: Fri Jul 13, 2012 2:45 am    Post subject: You have already found: http://www.yournavigation.org/ https://github.com/openplans/OpenTripPlanner/wiki/ http://bmander.github.com/graphserver/ and had a look at Dijkstra's algorithm and multinode route planning? In your example, you want to add the 3 values in column C which correspond to there being an A in column A and a C in column B; a C in column A and a D in column B; and a D in column A and a B in column B?_________________LibreOffice 3.6.6 on Fedora 18, LibreOffice 4.0.2 on Ubuntu 13.04 (Double Boot)
keme
Moderator

Joined: 30 Aug 2004
Posts: 2732
Location: Egersund, Norway

Posted: Fri Jul 13, 2012 5:50 am    Post subject:

Calc can't work directly with lookups matching on two fields. You need a workaround, probably merging the field values somehow.

 Code: X  A  B  C  D A  X  4  6  8 B  4  X  3  5 C  6  3  X  1 D  8  5  1  X

Then use MATCH twice to find the correct row and column, and then INDEX() to extract the distance value from that row and column.

With that approach you can also calculate correctly where the distance is not the same in both directions (one way paths).

With a database approach (which basically fits best for this task) you would add those "backwards" routes to your composite key table, like Robert Tucker suggests.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 8 Hours Page 1 of 1

 Jump to: Select a forum OpenOffice.org Forums----------------Setup and TroubleshootingOpenOffice.org WriterOpenOffice.org CalcOpenOffice.org ImpressOpenOffice.org DrawOpenOffice.org MathOpenOffice.org BaseOpenOffice.org Macros and APIOpenOffice.org Code Snippets Community Forums----------------General DiscussionSite Feedback
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum