Facet Grid by Province In Tableau

Are you even wondering how to show time-series data and keep information about a spatial location? If yes, this tutorial could be the answer you are looking for.

This tutorial inspired based @AD_VIZ Public Tableau. Please check his awesome dashboard in this link.

Let’s started with the problem when we use a map as a visualization. In Tableau especially, the chart will only inform you about one data point if we use a choropleth map and two continuous data for a scatter plot.

The facet grid or similar to GeoFacet in R can be the solution to show the combination of time-series data and spatial.

The first steps is to create a grid that represents each province in Indonesia. If you are interested to know detail about how I create the grid you can check this post. In a nutshell, I decode all the provinces to the specific row and column.

The data for Geofacet is available and you can download using this link. After downloading the data, you can drag it directly the Col into the Columns and Row into the Rows and you will get the same picture as below.

Decode all the provinces into specific rows and columns.

If we check the data in row one, column 14 and 16, there are provinces called NA. This is a dummy province to make a gap between Sumatra and Maluku, also Maluku between Papua.

Using Real Data

Let’s grab some data from the Indonesia Statistics Bureau (BPS) and for this tutorial, I will use this data called gender empowerment index. I already changed the format so it readable through Tableau, please download it in here.

Connect To The Data

In the first step, you will need to connect to both of data indo_grid and equality_gender.

After we have these two data, in the tab Data choose Edit Relationships. This allows us to choose a column as a key to combine the data.

Click Data and choose Edit Relationships

From this configuration, click Custom and choose Add, then select Name and Name Indo as a key.

Click Custom then Add, choose Name and Name Indo as a key.

Create A Geo Facet

To create a Geo Facet in Tableau, you will need these steps:

  • In the dataset equality_gender drag Name to the Details
  • Switch to the indo_grid dataset and make sure there is a red chain, red means the key is active between these two datasets.
  • Drag Col and Row from indo_grid respectively to the Columns and Rows.

After this, we can add more information. Switch dataset to the equality_gender again.

  • Create a new variable called Gender Equality Adjust.
  • Drag Year to the Columns and make sure to move the Year into Dimensions.
  • Drag Gender Equality Adjust to the Rows.
  • Change the visualization as an Area or Line.

We can make it even better

  • Duplicate Gender Equality Adjust and make it as dual-axis.
  • In the first metric, right-click and hover to the Quick Table Calculation and choose Percent of Total.
  • Right-click again in the same metric and hover Compute Using and select Name.
  • As an optional, you can use Synchronize Axis.
  • To make it tidier remove all Show Header for Col and Row as well with Year and Gender Equality.
  • Then in the indo_grid data drag Code to the Label in the first Marks Gender Equity.

Additional Steps

The purpose of these additional steps is, adding % difference from the maximum year compare with the minimum year. So we can see directly which area increasing and decreasing.

Create a variable called % Difference, with this code:

(SUM({ FIXED [Name]: MAX(IF [Year] = {MAX([Year])} THEN [Gender Equality Adjust] END) })
SUM({ FIXED [Name]: MIN(IF [Year] = {MIN([Year])} THEN [Gender Equality Adjust] END) })

Drag % Difference to the Color and Label in the second Marks of Gender Equality Adjust.

I assume that if equality closer to 50% means good. So, I decided to swap the color, negative blue and positive are orange. We can make the chart clearer using these steps.

  • In the tab, click Format and choose Borders.
  • In both Row and Columns, drag divider level to the left.

This is the final result of this tutorial with some adjustments that I made. So from the below chart, we can see the trend using area chart and also the overall difference indicated by the color.

A little note

Unlike R to create geofacet in Tableau, I need to wrangle all the data. First, the indo_grid data, I create a dummy province so it shows the map that I want. Also, in equality_gender data, I add a dummy province in this data with a null value in the gender equality column.

Second things, when I tried other data like population density/km, DKI Jakarta has a very high value so the area chart for other provinces can not be seen. Although it can be solved using Independent Axis this feature applicable only each row, it can not give Independent Axis for each province.

So, my final thought this type of chart can be useful for use cases like a combination of spatial and time-series data. In the context of Indonesia’s data, we need to consider the province that has outlier data and choose the correct metrics so the data still can be shown.

Leave a Reply