Timelines (13)

Link to the Timelines Video

Goals

  • Decide what kind of timeline fits your data.
  • Explore advanced functions of Tableau

Data

Women’s Soccer Top Goal Scorers

Trump Tweets

Dashboard – Soccer

Dashboard – Trump Tweets

Timeline (Basic)

We pulled this table from Wikipedia using the formula in cell A1. To save as an Excel file without the html formatting, I copied all of the contents and used Paste Special >> Text to save the text in an Excel file. Then did a little cleaning to remove footnotes, etc.

Timelines are not built in to Tableau by default. The trick is to tell Tableau when to begin.

We want to know when the top female goal scorers scored their 100th goal.

  1. Load the Women’s Soccer Top Goal Scorers Dataset
  2. Change the datatype of the Date of 100th Goal from String to Date
  3. Create a Calculated field to specify the beginning. MIN(0) Name your field “CALC: Beginning”
  4. Drag CALC: Beginning to Rows
  5. Drag Date of 100th Goal to Columns
  6. Use the drop down menu to make the Date Continuous and broken down by Day (not Year)
  7. To display events on the timeline, drag Name to the Details and National Team to the Tooltips. You should have points along the timeline noe.
  8. Note that there were some players with unknown dates. These players must be represented somewhere on the visual – generally with an annotation or footnote.
  9. Format based on your preferences – I prefer to have a thicker zero line, larger points, and to edit the tooltips

Gantt

Gantt charts are best for showing duration, overlapping time periods, and the beginning and ending of events. They are often used in project planning, but are also a great way to show when the best women’s soccer players overlapped with each other. We want to know when these 17 all-star soccer players played, and be able to answer: Who played with/against whom when?

  1. First split the duration on the hyphen. An automatic split should do this for you. This will give you a column with start dates. Change the datatype of both split columns to dates
  2. Calculate the duration of play DATEDIFF('year',[Active years - Split 1],[Active years - Split 2]) Call this field ‘CALC: Duration’
  3. Drag the Active years – Split 1 to Columns. Click the drop-down arrow and select Continuous and Years (in the first set of years)
  4. Drag Name to Rows
  5. Years are indicated by tick marks.
  6. Drag CALC: Duration to size on the marks card and change the Aggregation to Average
  7. Drag National Team to color on the marks card
  8. Drag Active Years to the Tool Tips
  9. If you have too much to show, drag Active years – Split 1 to the Filters and specify a narrower range of years.
  10. To sort by year they started playing, go to Name in the Rows shelf, and select ‘Sort’. Sort by Active years – Split 1 and Minimum
  11. Assign Colors, edit axes, format tooltips.

Spiral Timeline

Based on this tutorial

Now we will turn our attention away from sports toward Trump’s tweets during the first year of his presidency. This dataset comes from the Trump Twitter Archive

We’re just going to look at 2 years of data, though you can, of course, look at much larger segments. In order to plot the spiral we need to know two things for each tweet:

  1. How far through the year is the given day? This will determine the angle of the plot and how far round the circle we want to plot the data.
  2. How far away from the start (first tweet) is the given day? This determines the distance of the plot from the centre (without this, all the plots from each year would overlap).

So we use the datepart function to get the day of year from 0 to 365

  1. So we use the datepart function to get the day of year from 0 to 365. Create a new Calculated Field with the following equation: DATEPART('dayofyear',[Created At]) Name your field CALC: Day of Year
  2. Now figure out how many days each datum is from the start of data collection (i.e., how deep into the dataset is it). Create another field: ((YEAR([Created At]) - 2017) * 365) + [CALC: Day of Year] Name your field CALC: Total Days
  3. Next, the angle. We know that each day is 1/365th of the way round the circle. Tableau uses radians, but all you need to know is that there are (2 x π) radians in a circle. So the angle is however many 365ths of the year have elapsed, times (2 x π) Create another field: [CALC: Total Days] / 365 * 2 * pi() Name your field CALC: Angle
  4. Calculate X and Y using trigonometry (I warned this is an ADVANCED visualization): ([CALC: Total Days]) * (COS([CALC: Angle])) CALC: X ([CALC: Total Days]) * (SIN([CALC: Angle]))
  5. Drag ‘CALC: X’ to Columns and ‘CALC: Y’ to Rows, and Text to detail
  6. It’s a little tighter than we want. We’ll fix this with parameters. Select the drop down menu from the data pane and select ‘Create Parameter’ create one Parameter called ‘Parameter’ and set it to 4. Create a second Parameter. Call this ‘Inner’ and set it to 35.
  7. Return to edit CALC: X. The new Formula is: ([Inner] + [CALC: Total Days]/[Parameter]) * (COS([CALC: Angle])) The new formula for CALC: Y is: ([Inner] + [CALC: Total Days]/[Parameter]) * (SIN([CALC: Angle]))
  8. Drag the Retweet count to Size & Source to Color
  9. Edit the colors as you like, clean up the tool tips, remove the axes, and give it a title.