Going the Distance in Tableau: Dynamically Comparing Different Distribution Centers


Going the Distance in Tableau: Dynamically Comparing Different Distribution Centers

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 this next scenario, we are going to look at which distribution center is closest to a selected city. This is highly similar to the previous scenario with a change to the setup for the crosstab’s filtering. We need to have a two-level sort similar to the one before, while taking into consideration 1) whether a city is selected or not and 2) a rank of the distance to all non-selected cities. This is our Dynamic Sorting field below and on the left of the crosstab image.

Filtering with Dynamic Sort

We can place the selected city at the top and then our distribution centers using either the Distribution City Indicator or City Indicator field. Next, we can filter out every other city using the Dynamic Sort Filter field in our Filters card for a nice clean table. Shown below are views of the table and the Dynamic Sort Filter calculation used to pare down our data to just the selected city and our distribution cities:

distribution center comparison in Tableau

distribution center comparison in Tableau

We can then sort by the City Indicator field, which will place the selected city on top, followed by our distribution centers. The distribution centers will automatically be ordered by the Dynamic Sorting field on the left after we sort, due to that being the field initially splitting out our rows.

To clean up our table (and really any table produced in a similar fashion), we can right-click the pills on our Rows or Columns that we wish to hide and uncheck Show Header.

The next blog in our series explores clustering based on distance, so be sure to stay tuned for the final installment of our Going the Distance in Tableau journey.

More About the Author

Grant Eisenmenger

Analytics Consultant
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 ...
How to Wrangle Date Logic in Tableau TL;DR Build as much date logic into your calculations as possible, as opposed to using the Filters Shelf. Put your reference date (e.g. ...

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