OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Possible VLOOKUP formula with two items of dependant data?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
cmclaren1978
Newbie
Newbie


Joined: 02 Jul 2012
Posts: 4

PostPosted: Fri Jul 13, 2012 12:18 am    Post subject: Possible VLOOKUP formula with two items of dependant data? Reply with quote

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
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


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

PostPosted: Fri Jul 13, 2012 2:45 am    Post subject: Reply with quote

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?
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
keme
Moderator
Moderator


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

PostPosted: Fri Jul 13, 2012 5:50 am    Post subject: Reply with quote

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

Instead, how about ...
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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group