| View previous topic :: View next topic |
| 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 |
|
| Back to top |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
|
| Back to top |
|
 |
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.
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 |
|
 |
|