Drawing a Map in Tableau

Maps are used as a data visualization tool to analyze and display the geographically related data. This idea helps you to tell the story of your data better, in general.

There are several map types used for data visualization such as density map, heat map, choropleth map, proportional map, bubble map etc. It can be also divided into 2D maps, 3D maps or even static and dynamic maps etc.

In Tableau, you can create

  • Simple Map
  • Map from Spatial Files
  • Proportional Symbol Map
  • Point Distribution Map
  • Heatmap (Density Map)
  • Filled (Choropleth) Map
  • Flow (Path) Map
  • Origin-Destination Map
  • Dual Axis (Layered) Map
  • Filled Map with Pie Charts

See details from here.

If you would liketo see very interesting maps, visit Map Porn/Reddit.

Choropleth Map

In connection to a data variable, choropleth maps show separated geographic areas or regions that are colored, shaded, or patterned. This offers a method for visualizing values throughout a region, which might reveal variations or patterns within the space depicted.

The data variable represents itself in each area of the map using a color progression. Typically, this can be a transition from one color to another, a progression of just one hue, from transparent to opaque, from light to dark, or the full spectrum of colors.

When creating choropleth maps, it’s customary to encode raw data values (such as population counts) rather than using normalized values to create density maps, such as calculating people per square kilometer.

For example, the following plot shows the change in the number of COVID19 cases per 100.000 across the cities in Turkey.

Bubble Map

The area of each circle on bubble map is proportional to its value in the dataset, and circles are displayed over a specified geographic area.

A benefit of bubble maps over choropleth maps is that they can compare proportions across geographic regions without the problems brought on by the size of the regional areas. However, a significant drawback of Bubble Maps is that excessively large bubbles can overlap neighboring bubbles and map regions, therefore this must be taken into consideration.

For example, this map taken from New York Times shows the total number of COVID cases by County.

Point Map

It is also called a point map, dot density map, or dot distribution map.

By scattering points of the same size across a region, dots on a map can be used to detect spatial patterns or the distribution of data.

One-to-one and one-to-many dot maps each indicate a single count or object. For example, 1 point equals 10 trees in a one-to-many dot map.

The distribution of objects over a given area can be shown using dot maps, which also reveal patterns when the points cluster together. Dot maps are simple to understand and better at providing a summary of the data, but they are less effective at finding precise values.

The following point map taken from BBC News shows the distribution of the nuclear power plants across the kingdom.

As we can understand from the definitions, we should consider geographic variables which are lattitude and longitude used to draw a map and one target variable represented on the map as a color or point for map data visualization.

Note that maps are easy tools to create, but this does not mean that they are always the best option. For example, some data being related to geographic variables can be visually displayed better with dot plot or scatter plot.

How to draw a simple map in Tableau?

Tableau provides an easy way to build an interactive map, and that’s why big companies like Dubai Airports or Skyscanner are Tableau customers.

A geospatial data sets can be stored in different format. They can be an excel file, txt file or geoJSON file. Throught this course, we will consider excel file.

In Tableau, the maps are drawn using lattitude and longitude values of the locations. However, that does not mean that our data set always has to include these information. Fortunately, Tableau can generate them, and they will be used for mapping.

Drawing a world map in Tableau

Let’s start the drawing a world map which shows the importance of the countries. Please download “countries.xlsx” data set.

If you have a problem in connecting a data source and opening a new worksheet, please look at the previous lecture note.

Firstly, drag and drop your generated geographic variables.

If you would like to draw an empty map, here it is. However, if you would like to a specific map like point or bubble etc, you should go further. The country names are written in County column. Your next move is to drag and drop country name onto details under Marks.

You have a point map! Now, we will convert it into a choropleth by drag and drop your numeric variable, which is importance, onto color bar under Marks.

Then, here is your map.

Here is a trick for you. If you fill color to your plot based on a numeric value, you should have a color scale where the orange represents the lowest and the steelblue represents the highest.

Now, apply this by selecting Colors -> Edit Colors -> Orange - Blue Diverging, respectively.

The result is

You can manipulate your map by using map bar on the top of your screen.

Drawing an Europe map in Tableau

Please download “working_hours.xlsx” data taken from Eurostat. The data file includes the average number of actual weekly hours of work in the main job across the Europe.

No geographic information. In this case, you will generate it by following the steps given below. Note that you always use the variable including the location name.

After converting your data type, then select your geographic variable, which is Country, and click on Show me button to draw a map.

If we would like to create a bubble plot, we will drag and drop our numerical variable onto size tab under Marks. However, we decide that the choropleth will be a better way. That’s why drag and drop hour variable onto color.

The choropleth map is ready, but we can make it better by removing countries whose information are not available. Select map -> background layers. Then remove the layers that you want.

If you remove all layers, you have

Continue to manipulate it by adding label and title. (Use label button and title bar)

Drawing a Turkey map in Tableau

Please download “covid_turkey.xlsx” data, which shows the risk levels of the cities based on number of cases between 19-25 March 2022.

We will do what we did in the previous example. However, we choose state/provinces when we create our geographic variable because we have province name as a location variable.

After that, we select a map from show me window.

Then, drag and drop the variable used for coloring our map, which is Risk to color bar.

To change the color of the levels, click on Color and assign the appropriate color to each level.

Not done yet…

Remove backgrounds, assign label and title, then reorder your legend box.

Ops! We still have a problem. Some province names are not appeared.

Select label -> allow labels to overlap other marks

Do not under estimate the power of the maps. They may even make you a fame for a while.

Exercise 1

Please download the “election.xlsx” data, and imitate the map given below.

Creating a Dashboard in Tableau

A dashboard is a collection of several views, letting you compare a variety of data simultaneously. (Tableau)

A well-designed dashboard can align your organization’s efforts, help uncover key insights, and speed up decision-making.

For example,

Crime in India

Sales Summary

Check for more

Advice for building a good dashboard

  • Know your purpose and audience: Before creating your dashboard, you should know what your dashboard try to say. Are you presenting a conclusion or question?

    Also, you know the characteristics of your viewers. Are they familiar to the your topic or unfamiliar to your topic?

  • Leverage the most viewed spot: Most of the viewers scan your content starting at the top left corner of it. Thus, it is suggested to place your main content on the upper left corner of your dashboard.

  • Limit the content number: It is suggested to put at most four content on your dashboard. If you add too many details, then it will be hard to explore and understand your dashboard.

  • Add interactivity: You can courage your audience for exploration by adding interactivity using some tools such as filter button or highlight option.

Please import “happinessscore2022.xlsx” file.

The data set has the happiness score of the 147 countries in the world with some additional information for each country.

Now, we would like to create a dashboard that shows three plots.

  • The world map colored by happiness score

  • The distribution of happiness score by continents

  • The relationship between happiness and GDP

In Tableau, the dashboards are created by combining worksheets. So, we will create multiple worksheets, then we will combine them.

Start with mapping. The mapping procedure was given above.

Please name your worksheets to remember which worksheets has which content. Then, add new worksheet.

In this worksheet, we will illustrate the distribution of happiness by continents.

Since we aim to display the distribution of one quantitative variable over a qualitative variable, box plot can be an appropriate tool for our purpose.

Select your variables, and then, select box-and-whisker plot under Show me button. While doing this, do not forget to remove aggregate measure, also filter your data since your data has “NULL” observation.

As a last step, we will look at the relationship between GDP and Happiness Score. Add your new worksheet, and draw a scatter plot for these two variables. To find out how to draw it, check previous lab note.

We draw the plot, but it does not have a good appearance because of x axis limits. We have an empty space which makes the plot uglier. To set the axis limits.

Double left click on the x-axis.

Then, set fixed option and enter your limits.

Then, add country name as labels by draging and dropping the country variable onto label screen. Ta ta!

We are ready to take on! Let’s combine them.

First select the “Create New Dashboard” option from the menu, or just click on the Dashboard button in the bottom menu.

The next screen will be inside the dashboard window that looks like the following image.

On the left-hand side, the worksheet visualization created will now be available. Creating a Tableau Dashboard is simple, just drag and drop the worksheets onto the Dashboard Canvas.

The left-hand panel of the dashboard provides you with various options for setting the presentation screen according to the device. The screen size can be manually set as well.

Firstly, we will change the screen size by selecting size menu on the left hand side.

Then, drag and drop your most important content, which is map for this example on the canvas.

Then, change size of the map and add the other objects by dragging and dropping.

Ta ta!

The dashboard is ready. What we will do next? Publish it! Press save to Tableau Public option.

Sign in your free account.

After that, name your dashboard and save.

Here is the result. You can check it from here.

Exercise 2

Please download happinessturkey.xlsx dataset. The dataset has province names, GDP per capita in 2020, happiness score in 2018 and region names.

Create a dashboard we created above for Turkey using the same variables and same plots.

Your dashboard looks like this.

Data Cleaning (Cleansing) in Tableau

The quality of the data is one of the most important conditions to produce a good results in data science, data analytics or data visualization. It does not matter either you have well-working algorithms or great tools, the quality of your output depends on your data input. That’s why it is important to be sure that the data under the study is properly refined.

Data cleaning is a foundational process in the data science lifecycle and its role cannot be overemphasized when trying to uncover insights and generate reliable answers. More often than not, data will always be dirty in the real world, and data cleaning cannot be completely avoided such that it is estimated that it takes 80% of the data analysis process.

This can involve finding and removing duplicates and incomplete records, and modifying data to rectify inaccurate records. Unclean or dirty data has always been a problem, yet we have seen an exponential rise in data generation over the last decade.

There is no absolute way to dictate the exact steps of the data cleansing process, as the process is different for each dataset. However, it’s important to create a template for your data cleansing process and make sure you’re doing it right every time.

How do you clean data?

  • Step 1: Remove duplicate or irrelevant observations

  • Step 2: Fix structural errors

  • Step 3: Filter unwanted outliers

  • Step 4: Handle missing data

Components of quality data

  • Validity. The degree to which your data conforms to defined business rules or constraints.

  • Accuracy. Ensure your data is close to the true values.

  • Completeness. The degree to which all required data is known.

  • Consistency. Ensure your data is consistent within the same dataset and/or across multiple data sets.

  • Uniformity. The degree to which the data is specified using the same unit of measure.

Before data cleaning can properly be done, it is important to understand how it got dirty in the first place.

Tableau has a specific product for data cleaning process, Tableau Prep. However, we can still clean our data using Tableau Desktop.

Let’s import the dirtydata.xlsx.

After connecting the data source through Tableau.

The first thing you should do in data cleaning with Tableau is to run Data Interpreter on the left panel.Data Interpreter can give you a head start when cleaning your data. It can detect things like titles, notes, footers, empty cells, and so on and bypass them to identify the actual fields and values in your data set.

Then, see the magic.

After this process, detect the problem one by one and fix them using some functions in Tableau such as changing column names, data types or create calculated fields by using SQL codes.

Note that most of the data cleaning process in Tableau Desktop requires SQL functions.

Let’s start changing the column names by clicking on the existing ones and replace them with the correct ones.

Then, we see that gender column has different levels. Thus, we need to rearrange them. We wish to have only FEMALE and MALE. This means that we need to create a new variable by typing SQL codes.

Then, hide the old column.

After that, fix the software column in a similar way. Before starting your procedure, display the distinct values in the worksheet.

Note that UPPER makes all entries with upper letters and TRIM removes the spaces in the entries.

Then, we see that time variable and unit variable are inconsistent. Fix the problem in a similar way.

After these steps, we see that letter inconsistency in Buy column and incorrect calculation in Net column. To overcome this problem, I will create a calculated field again and type the SQL functions that works well.

Lastly, we have only Date column left to fix. As seen from the picture given below, the data type of Date should not be text. It has to be date object.

Ops! We have NULL.

Since all dates are same, we can replace which value should be imputed to NULL. Use IFNULL and MAKEDATE commands.

Today’s class is over.

Your second quiz is available on ODTUClass.