Step 1: The Data
To begin, we need to identify some needs. To create the Radial Lasso in Tableau, we need data to plot the point. Here's the thing, the Lasso isn't really a part of the actual data, it's in support of it. We are merely using it for visual context to identify the circumference of our area. Additionally, we are going to make the central point be driven by a parameter, so we don't need to tie this to the points individually. With that being said, what do we do? Full Join
To begin, we need a dataset that already has the L attitude and Longitude in it. We don't yet have the ability in Tableau to reference the Generated Lats and Longs Tableau provides, so we need our own. We also need a dataset that has one column, Path, that has 360 rows. Rather than using this as a cross-join scaffold, I am going to instead Full Join it to my dataset. This will allow me to "add" it the data, without effecting the granularity of the dataset. This technique is very beneficial when doing layering, as we can bring two different datasets into one, without either one effecting the other.
Step 2: The Distance Calcs (For filtering)
Now that we have our dataset prepared, we need to start creating some calculations. First things first, let's create our Parameter. This is going to be used to to determine our central point, or the location we want to map the Radial Lasso around.
For this example, I am using a combined field of City and State.
Now that we have our Parameter, we need to use some LoDs to get the Latitude and Longitude of that selected City, State on every row.
These calculations are what we are going to use to find the distances (in miles) from our central point, to all others. This will allow us to "Filter out" any points that are going to be outside of our desired circumference.
[SelectedLat1]
{MAX(IF [City and State] = [Parameters].[City and State] THEN [Latitude] END )}
[SelectedLon1]
{MAX(IF [City and State] = [Parameters].[City and State] THEN [Longitude] END )}
These calcs looks to see if the City and State match our Parameter, if it does, we grab those coordinates, and wrap them in a Fixed LoD that put's them on every record. This will allow us to access it very easily.
Now for a lot of Calcs. The formula I am using is Haversine, or great circle distances Additional information here https://rosettacode.org/wiki/Haversine_formula
To start we need to transform our Lats and Lons to be relative to a circle.
[lat1]
[selectedLat1]/180*PI()
[lon1]
[selectedLon1]/180*PI()
[lat2]
[Latitude]/180*PI()
[lon2]
[Longitude]/180*PI()
As you can see, we are taking our Parameter driven Lats and Lons, as well as, our Data's Lats and Longs, dividing it by 180 and multiplying it by PI.
Next we need to find there difference between those points.
[dlat]
[lat2] - [lat1]
[dlon]
[lon2] - [lon1]
Finally, we bring it all together and create the Distance Calculation. This will tell us (in miles) how far a point is from our central point (the point chosen in the parameter).
[Distance]
ROUND(3961 * 2 * ASIN(
SQRT(
POWER(SIN([dlat]/2),2) +
POWER(SIN([dlon]/2),2) *
COS([selectedLat1]/180*PI()) * COS([Latitude]/180*PI())
)
),2)
Perfect! Now that we have our Distance calculation, we can create a parameter and filter to determine which points we want to keep in our visualization.
[Distance Filter]
[Distance]<= [Miles] OR NOT ISNULL([Path])
[Miles] is simply a Parameter that let's users input the distance they want. I am also including a provision to include my PATH (my circle data set we Full Joined in), which will allow us to still plot those points on our map. This will work as a great circle around the central point, i.e. I can select 100 miles, and get only the points that are within 100 miles (as the crow flies) from my selected point.
Perfect! Even though I have points all around the country, I am limiting those points to only be within 500 miles of the point I selected.
Here's the rub though, it's very hard to see where my central point it, or the total circumference of the area I am filtering on.
Step 3: The Radial Lasso Calcs
What I am about to show comes 100% from the amazing Emily Chen. She created a blog post on how to map a Circle on a map, and it is just fantastic! I am directly using here calcs here (with a slight mod). I recommend you checking out her post http://www.lesviz.com/blog/2016/09/13/how-to-draw-a-circle-in-tableau/
[Circle Latitude]
DEGREES(ASIN(SIN(RADIANS([selectedLat1]))
*COS(([Miles])/3961) + COS(RADIANS([selectedLat1]))
*SIN(([Miles])/3961)
*COS(RADIANS([Path]))))
[Circle Longitude]
DEGREES(RADIANS( [selectedLon1] )
+ ATAN2(COS(([Miles])/3961)
-SIN(RADIANS( [selectedLat1] ))
*SIN(RADIANS( [Circle Latitude] )),
SIN(RADIANS([Path]))*SIN(([Miles])/3961)
*COS(RADIANS( [selectedLat1] ))) )-90
If these calcs seem scary, don't worry, this can be copy/pasted in your solution.
So now that we have our Lasso Calcs, we need to bring it in together with our actual points. We want to have a single X/Y column so that we can leverage Tableau's mapping service (there are workarounds to get Dual Axis maps but let's keep it simple).
[X]
IF NOT ISNULL([Path]) THEN [Circle Longitude] ELSE [Longitude] END
[Y]
IF NOT ISNULL([Path]) THEN [Circle Latitude] ELSE [Latitude] END
For these calcs, I am just doing conditional plotting. This is where the Full Join comes in. For the dataset that has my Path field, I want to grab the Circle coordinates, and then my actual dataset I want to grab the raw coordinates.
Sweet, now that the hard part is done, we need to do some additional cleanup to make this look really good.
Step 4: A single point line is just a circle.
First trick coming at you fast! As you saw in the first image, I am using only a single X/Y, yet it appears as though I have two marks types, Line and Circle. So here is the trick, a single point line, is just a circle. So we can manipulate that feature to give the illusion of two chart types, even though it's really only one.
We being by changing our Mark Type to a Line.
Well that didn't work. Reason being, Tableau has no idea how to draw the correct oath right now. There are points everywhere. Luckily, we don't have to do much to resolve this, we simply take the [Path] field from our Circle Dataset and place it on the Path Mark. This will draw the outer line correctly for us. And, since our actual data didn't have a "Path" field, it will break those away, and make them individual marks.
Starting to come along! This is looking pretty good at this point, but we can improve it. For one, let's deal with the sizing. I want the Actual points to be sized by their Sales, and I want to make the line much thinner, so it doesn't draw too much attention. Luckily, we can do this by dragging sales onto the size mark.
Since our Circle Dataset didn't have any sales, we can use that (along with adjusting the size range) to make the line extremely thin, while giving our points a larger size. Remember, these points are circles, they are single mark lines, but we can treat them the same way as a circle.
Next, we want to separate these two elements even more visually. I want the Circle line to be a completely different color scheme from my points. So we need to create a calc to do that.
[Color]
IF NOT ISNULL([Path]) THEN -1
ELSE [Sales]
END
What I am doing here is setting up a color range I can manipulate. I know my sales are never going to be below zero, so I set my Circle to be that. Now I can create a color scheme that will "split" these two up.
Sweet. We can use a Custom Diverging color palette, with steps ,and a center point, to essentially create two different color palettes. Anything that is negative will be black, whereas anything positive will be on a range over blue colors (I really like this trick).
At this point, you could be finished, by I want to go for a slightly more modern look. Instead of having that line be solid, I want to make it dashed. So how do we do that? We (once again) manipulate features in Tableau.
As we saw by putting the [Path] field on the Path Mark, Tableau is breaking elements up into partitions. So to get our circle Dashed, we need to break up the circle into smaller partitions.
[BreakLine]
CEILING([Path]/2)
This calc will group our points into buckets of two. We can take this calculation, and put it on the detail shelf. Tableau will use this, along with the path, to only connect the points within each partition. This will give the illusion of a Dashed Line.
Woot! I would say, "And that's it", but this was a lot. That being said, there are a lot of visual and analytical benefits we can get from this chart.
I hope you learned a few tricks, and saw Tableau in a different light. Tableau has a lot of amazing features, but it's when we use those features in unconventional ways, that the real fun begins.










3 Comment
Thanks for this Rody! This was a great addition to a marketing tool that I am working on.
BalasI can't seem to find the dataset SuperStoreGeography. Is that a snippet of the superstore data in Tableau with additional Lat Lon added by you?
BalasHard Rock Hotel and Casino Richmond - Mapyro
BalasFind Hard Rock Hotel and 충청북도 출장샵 Casino Richmond, VA, United States, ratings, photos, location, Hard Rock 거제 출장안마 Hotel & 부산광역 출장마사지 Casino is the only casino in Richmond, Virginia to have 부천 출장마사지 Rating: 4.2 문경 출장안마 · 946 reviews