Tableau Viz Study & Analysis (TVSA) — P1.1

Three Steps to Find Your Path — P1

Jane Hu
The Startup
Published in
4 min readSep 11, 2020

--

Photo by Mihály Köles on Unsplash

Second year into Tableau learning, I have been reading and practicing, but not until very recently did I finally encounter that “aha” moment about Tableau custom charts, thanks to Ken Flerlage’s posts.

The hardest part of self-learning, to me, is to find the right things to learn, and to find the right path. In school you can simply follow what is taught by the teacher in the textbook. However, for a quickly-upgrading software like Tableau, there is lack of a clear and specific learning path for one to follow. Making things worse, there is way more than enough learning materials available online for one to choose from. After two years of learning, I still am not confident about creating insightful and fancy visualizations on my own like those zen masters. What worries me the most is that I don’t even know exactly what I need to but don’t yet know about this software. Thus, I decided to start writing this Tableau Viz Study & Analysis (TVSA) series, with a few objectives in mind:

  1. to organize my Tableau learning notes
  2. to share my Tableau learning experience
  3. to improve my writing skills.

Drawing a Path in Tableau

“Every moment is right moment for taking right decision and right action.”

― Amit Ray, Walking the Path of Compassion

The curiosity about how to create a path (with a direction) in Tableau originated from this visualization.

Visualization by Max Roser in Happiness and Life Satisfaction

It may not be stranger to people that one way to visualize the relationship of two quantitative variables is to use a scatter plot. But what about adding a third dimension to it, the time along which the original pair of values change together? This visualization provides a perfect solution showing the paths and directions.

Drawing a path in Tableau is not as easy as imagined. It requires at least two data points to form a path. To realize the above visualization in Tableau, it means for each country, at least two separate records / rows are needed, one indicating the first available observation, and one indicating the last. However, commonly we’d find the original data structure to be unpivoted, e.g. for each country / row, there are two fields / columns for the first and last observations. The real magic, as detailed in the following post, is to restructure the data so there is one separate row for each point in the path.

Self-union to Create Multiple Rows for Each Record

The technique used here to “pivot” columns into rows is self-union. This, combined with data densification, is very common in more advanced examples, to create more complex curves.

Self-union duplicate the records. For each line to draw, the two points to be connected are listed in two separate rows, pairing along the airline dimension in this example. Each row indicates either the source airport or the destination airport, together with the X & Y coordinates, which are longitude and latitude in this case.

To go through each step of drawing the path:

  • drag longitude to columns, and latitude to rows
  • drag both source and destination airports to Detail card, in order break it up to all separate airports
  • change the mark type to line
  • set the drawing order by assigning a specific dimension to Path card (in this example the author created a Path ID field to serve this purpose, but I believe, and tested true, that using the Table Name field automatically created after the self-union would suffice)

I had some trouble clearly understanding the implications of the second step, so let’s think through it.

After the self-union, the data structure looks like this:

After plotting all longitudes and latitudes on the screen, both are aggregated, so only one dot is shown. Draging both SourceAiport and Destination Airport to the Detail card serves the same purpose as using Airline, as the level of detail is the same for both choices. Finally, adding the Path dimension changes the viz LOD to one dot for each row, so all source and destination airports’ longitudes and latitudes show on the screen, instead of being aggregated along dimensions such as airline.

So far is everything needed to create a path from a data structure, where the multiple points being connected to form this path are listed as separate columns / fields in the same row / record.

--

--