Going the Distance in Tableau: Greater Interactivity with Parameters


Going the Distance in Tableau: Greater Interactivity with Parameters

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.

In the last blog, we looked at comparing all locations against a single, static point.

Now, we can build on this and account for a selection of points in our distance calculation by using a parameter. This will enhance the interactivity of our viz and allow selection of a comparison city from a list of cities:

Going the Distance in Tableau

Here, I use a string parameter to list out my five distribution centers; if you need a performance boost, try using an integer parameter and setting the Display As to your city names. Then I create two calculated fields, both tied to the one parameter, separately referencing the latitude and longitude of the five parameter members. I then include these two calculated fields in my distance calculation:

Going the Distance in Tableau

Going the Distance in Tableau

Going the Distance in Tableau

And if you want to copypasta:

3959 * ACOS


SIN(RADIANS([lat])) * SIN(RADIANS([lat parameter calc])) +

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

COS(RADIANS([long parameter calc]) - RADIANS([long]))


3959 is half of the Earth’s diameter in miles. If you are using kilometers, this needs to be 6371 km.

The next post in this series will take this a step further and focus on going completely dynamic with table calculations.

More About the Author

Grant Eisenmenger

Analytics Consultant
Do I Need Row-Level Security (RLS) in Tableau? “Do I need row-level security (RLS) in Tableau?” This question, or a version of it, is brought to us often. RLS can seem ...
Introducing InterWorks Translate, Our DataDev Hackathon Project At InterWorks, we have always been a group of tinkerers. Near the end of last year, we had the opportunity to launch the Amazon ...

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
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