## VizWiz

Launch, grow, and unlock your career in data

## How to Calculate the Distance Between Two Points

In this tip, I show you how to use the Distance function in Tableau to calculate the distance between two points. I also show you how to use the Makepoint and Makeline functions to draw the map.

## Social Connectedness in the United States

NOTE: The insights you see in this post are based on an article by The Upshot from September 2018. Some of the insights and use cases demonstrated are the same and are shown in Tableau for demonstration purposes.

----------------------------

When I first saw the map that The Upshot created in How Connected Is Your Community to Everywhere Else in America? I was blow away by the simplicity of the map and how easy it is to understand the relationships of people in the United States via their Facebook friendships. The first thing you need to understand is the metric "Social Connectedness Index". You can access the data I used via the same link.

Here's the formula Facebook uses to calculate the index:

Social Connectednessi,j measures the relative probability of a Facebook friendship link between a given Facebook user in location i and a user in location j. Put differently, if this measure is twice as large, a Facebook user in i is about twice as likely to be connected with a given Facebook user in j.

In each dataset, we scale the measure to have a fixed maximum value (by dividing the original measure by the maximum and multiplying by 1,000,000,000) and the lowest possible value of 1. We also round the measure to the nearest integer.

I was not able to match the color scale in The Upshot exactly, so instead I used a table calculation that ranks each County in the U.S. compared to the County selected by the user.

Close enough for me!

The data has columns for the State/County of the user and for State/County of the friend. To ensure that I was only looking at friends for the County selected, I used Parameter Actions to filter the user to the County and State selected. The rank calculation then only uses the SCI for the friends.

Now let's look through some of the use cases as described in The Upshot.

# DISTANCE IS MOST IMPORTANT

People are more likely to be friends with people that live nearby. That makes sense. Consider these four counties that I lived in while I lived in the U.S. Clearly relationships on Facebook are more likely with people that lived near me.

# STATE LINES ARE BOUNDARIES

In some counties (like the four below, friendships drop significantly outside State borders.

# MIGRATION PATTERNS

People from certain areas of the country have migrated to other areas in the country over the course of many decades. We can see these patterns by looking at Chicago and Milwaukee. The southern counties were typically related to the slave trade, and the people in the south gradually migrated north after they were freed.

Migration patterns aren't limited to history. Consider counties in the Northeast. Nearly all of them have a strong relationship with coastal areas in South Carolina and Georgia and all of Florida. These are called snowbirds, people that migrate south for the winter.

# PHYSICAL BOUNDARIES

Friendships in some counties are limited by geographical boundaries. For example, friendships for people living in Belmont County, Ohio don't cross the Appalachian Mountains in West Virginia.

While people in Scott County, Arkansas don't have friends on the other side of the Mississippi River.

Have some fun with the interactive version below.

## How to Add a +/- Indicator to a Drill Down Action

In this tip, I show you how to add an indicator before the selected dimension for a set action. This can also be done with a parameter action.

For example, if you click on the East region to drill down to the State level, you will see + East as an indicator. I also show you how to use • as an indicator.

## How to Create a Calendar Widget for Filtering

In this tip, I show you how to create a calendar to use as a filter on a dashboard. This calendar is a heatmap, thus providing additional information in your dashboard that a regular date filter cannot.