Jim Dehner

Tableau How to’s,  Use Cases, and Forums Questions

Hey #DataFam

Let’s Talk

Open for

## "Zoom In" – to Points on Map

Recently there have several Forum posts asking how to find all the points that are within a radius of a point and to be able to "zoom in" on the map – something like “I want to identify client locations are within 20 miles of each of our 5 office locations of our plant locations”  –

Not an uncommon question – and very solvable with Tableau – but being able to "Zoom in" requires a bit of a hack

Like a lot of solutions in Tableau, you need to think backward. First, we need to determine the distance from each office to each client location in the data – Then apply a filter that eliminates the points a greater distance away.  Not difficult but a lot of data

#### Step 1 – Shape the Data

You need to have the longitude and latitude of each office and each client location – sorry you won’t be able to use the Tableau generated longs and lats in calculations, so they need to be loaded with the data – keep the files separate – one for the office and one for the client locations.

To get the solution we need to determine the distance from each office location to every client site and will require connecting the files with a Cartesian join

The join expands the data set with a separate row for each client location/office site combination

#### Step 2 – Determine the distance from the office to each client

I’ve used a LOD that looks at each Office location and determines the distance to every Client location

{ FIXED [Client Loc ID],[Office Loc ID]   :avg(3959 * ACOS(

### Note: I used the explicit formula rather than the Distance spatial function added in version 2019 –

The fixed LOD can be read in words as "for each combination of the office and client location" calculate the “as the crow flies distance flies using a complex trig formula —

#### Step 3 Create a Parameter to enter the radius and a filter based on the parameter

I used a floating-point parameter and used a range up to 60 miles with steps of 10 miles – you can use whatever fits your analysis

Then add a simple filter that limits the distance between the city center to the value in the parameter – place it on the filter shelf and set it to TRUE

#### Step 4 – Create the Map

The Viz is a dual-axis map – one layer contains the Client locations the other the Office sites
Filters are added on the Office site location and the Boolean distance filter.

I made the Office locations stars – could be any shape – and I use the State dimension to vary the color of the client locations

Convert the map to Dual Axis then go to the Map button on the top ribbon, open and select Map Layers – in the box that opens you will be able to select the style and the layers you want to see

#### Step 5 – the Zoom feature

Finally, the Zoom feature is controlled by the radius – the smaller the radius the more the user "Zooms" in and conversely larger radii will "Zoom Out"  BUT you MUST UNPIN the map and UNSELECT the Pan and Zoom on the Map Options to avoid the map being locked at a zoom level and office location

Bring the map and filter and parameter to a dashboard and annotate as needed

I have a similar map on my Tableau Public site at

Feel free to download it (or any other file on the site) to use as a model

Jim