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:
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:
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.
The post Going the Distance in Tableau: Greater Interactivity with Parameters appeared first on InterWorks.