1 2 Previous Next 24 Replies Latest reply on Sep 14, 2019 8:37 AM by Don Wise

# Maps - Mileage

Is there a way to calculate the mileage (distance) between two addresses, or between two zip codes?  Any help is appreciated.

• ###### 1. Re: Maps - Mileage

Currently you will need the Long and the Lat of the 2 points and use the formula shown below

watch for changes in future releases

3959  * ACOS

(

)

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

1 of 1 people found this helpful
• ###### 2. Re: Maps - Mileage

What does 3959 * ACOS mean?  I assume that is part of the formula?

• ###### 3. Re: Maps - Mileage

3959 is a constant for miles times the arc cosine   ---  in tableau that is ACOS

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

• ###### 4. Re: Maps - Mileage

So, when you have a field [Zip Code], how do you use the formula for each zip code value?  I assume you must first designate which zip code is zip code 1, then write a separate formula for additional zip code value?

• ###### 5. Re: Maps - Mileage

You need the lat and long values for the centroid (the geographical center) of the zip code to plug into that formula.  You can't do it with zip code values alone.

• ###### 6. Re: Maps - Mileage

Right.  I did that.  I came up with this:

Tableau is telling me that I need a " , " or a " ) " somewhere? What did I do wrong?

• ###### 7. Re: Maps - Mileage

Besides taking out and replacing the brackets around the last coordinate, the -82.8093.

• ###### 8. Re: Maps - Mileage

The easiest way to tell is to edit in Notepadd ++ or something similar that can do simple syntax and bracket matching for you.

• ###### 9. Re: Maps - Mileage

I've matched up all brackets but something is not working?

If I have 43004 for my center point zip code.  What would be the formula to tell you how many miles away are zip codes 43081 and 43110 ?

• ###### 10. Re: Maps - Mileage

Hi Michael,

Both Jim and Michael Gillespie are correct in that you'll need both some calculations and latitude/longitudes for each centroid point.  In the attached 10.2 version example, I'm using a list of California Zip Codes and their latitude and longitudes.  Please look at the calculations for Starting and Ending Lat/Long and then the subsequent Distance Calc which is based on those four other calculations. As Jim noted, stay tuned, as this will be easier to do in a future release.  Hopefully it points you in the right direction?  Best, Don

PS - If you need to GeoCode U.S or U.K. addresses you can batch geocode them at: https://www.geocod.io/  Up to 2,500 per day...for free!

• ###### 11. Re: Maps - Mileage

Unable to complete action

Errors occurred while trying to load the workbook . The load was not able to complete successfully.

Error(5404,66): no declaration found for element 'simple-id'

Error(5404,66): attribute 'uuid' is not declared for element 'simple-id'

Error(5405,17): element 'simple-id' is not allowed for content model '(((layout-options?)|(repository-location?)),table)'

Not sure if that is enough info to tell you why it didn't open?

• ###### 12. Re: Maps - Mileage

Hi Michael,

What version of Tableau are you on?

• ###### 13. Re: Maps - Mileage

2018.2.4

• ###### 14. Re: Maps - Mileage

Newly attached 2018.2 version...  Best, Don

1 2 Previous Next