Going the Distance in Tableau: Fixed Point Comparisons

Data

Going the Distance in Tableau: Fixed Point Comparisons

In this series, we will explore different types of calculations involving calculating distance. From a simple iteration to geographic clustering, we will take your data as far as it can go with Tableau.

Calculated fields are awesome. They can be used to discover incredible insights in your data by using fields from your original data source. And if some of those fields are latitude and longitude, they can be used for more than just plotting. You truly can use calculated fields to go the distance.

Distance Calculations in All Their Variations

In this blog series, we are going to break down several types of distance calculations in Tableau, including:

  1. A fixed point and all others, using a calculated field
  2. A point selected from a small parameter and all others, using a calculated field
  3. A point selected from an expansive parameter and all others, using a table calculation
  4. A point selected on the map and all others, using a set action and a table calculation
  5. A point selected from an expansive parameter and a list of a few points, using a table calculation
  6. Multiple points selected from multiple expansive parameters, which can be used for distance clustering, using a nested table calculation

Comparing a Fixed Point to All Others

In our first scenario, I am looking at distance from a central distribution point, which I have decided is in Oklahoma City at the crossroads of Interstate-35 and Interstate-40. I am then going to use that to look at shipping cost per mile.

Here is our calculation with OKC’s coordinates for reference:

distance calculations in Tableau

And if you want to copypasta:

3959 * ACOS

(

SIN(RADIANS([lat])) * SIN(RADIANS(35.4720)) +

COS(RADIANS([lat])) * COS(RADIANS(35.4720)) *

COS(RADIANS(-97.5211) - RADIANS([long]))

)

 

3959 is half of the Earth’s diameter in miles. If you are using kilometers, this needs to be 6371 km. OKC’s latitude and longitude coordinates are 35.4720, -97.5211.

And our Shipping Cost per Mile calc:

distance calculations in Tableau

This information can be attained in a slightly different way by using a scatterplot and trend lines:

distance calculations in Tableaudistance calculations in Tableau

Y-intercept              Coefficient

This model gives us additional context for our evaluation of shipping cost per mile. The Y-intercept is effectively a measure of estimated fixed cost for shipping, while the slope coefficient is the cost per mile. We can see both of these measures increase when we look at orders that had a Critical priority and were shipped the same day.

The next post in this series will be discussing comparing distance using parameters, thus affording us greater interactivity. Stay tuned.

More About the Author

Grant Eisenmenger

Analytics Consultant
Going the Distance in Tableau: Clustering Based on Distance The final example of using distance calculations in Tableau looks at clustering cities based on their relative distance to a selected ...
Going the Distance in Tableau: Dynamically Comparing Different Distribution Centers In this next scenario, we are going to look at which distribution center is closest to a selected city. This is highly similar to the ...

See more from this author →

Subscribe to our newsletter

  • I understand that InterWorks will use the data provided for the purpose of communication and the administration my request. InterWorks will never disclose or sell any personal data except where required to do so by law. Finally, I understand that future communications related topics and events may be sent from InterWorks, but I can opt-out at any time.
  • This field is for validation purposes and should be left unchanged.

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072