Gantt Charts

Gantt Charts can be incredibly useful for understanding any series of events with a duration, especially if those events have some kind of relationship. Visually, they are very useful for determining whether certain events overlap, have dependency, or take longer or shorter than other events.

The following Gantt Chart shows a series of processes that run when an application is started. Some of these processes run in parallel, and some are clearly dependent on others. The Gantt Chart makes these dependencies clear:

To create a Gantt Chart in Tableau, you can select the Gantt mark type on the marks card dropdown. This places a Gantt bar mark starting at the value that was defined by the field defining the axis. The length of the Gantt bar is then defined by the field on the Size card, with positive values stretching to the right and negative values to the left.

At the hospital, you might want to see each patient visit to the ER in 2018 and understand how long each visit lasted, whether any patients returned to the hospital, and how much time there was between visits. The following steps give an example of how you might create a Gantt Chart to observe these patterns:

  1. Place Department on Filters and keep only ER.
  2. Place Date of Admit on Filters, select Years as the option for filtering, and keep only 2018.
  3. Place Date of Admit on Columns as a continuous Exact Date or as a Day value (not day part). Notice that Tableau's automatic default for the mark type is Gantt bars:

  1. Place Patient Name on Rows. The result is a row for each patient. The Gantt bar shows the date of the order. In most cases, we'd also want to add a unique identifier to the view, such as Patient ID, to ensure that patients who happen to share the same name are distinguished in the visualization. This is not necessary with this dataset, as all names happen to be unique, but it may be vitally important when you work with your data.
  2. The length of the Gantt bar is set by placing a field with a value of duration on the Size shelf. There is no such field in this dataset. However, we have the Date of Discharge, and we can create a calculated field for the duration. We'll cover calculations in more detail in the next chapter. For now, select Analysis from the menu and click Create Calculated Field.... Name the field Days in the Hospital and enter the following code:
DATEDIFF('day', [Date of Admit], [Date of Discharge]) 
  1. The new calculated field will appear under Measures in the data pane. Drag and drop the field onto the Size shelf. You now have a Gantt Chart showing when patients were admitted and how long each visit lasted.
  2. Sort the Patient Name field by selecting Sort from the drop-down menu on the field on Rows in the view. Select the following options:
    • Sort By: Field
    • Sort Order: Ascending
    • Field Name: Date of Admit
    • Aggregation: Minimum:

When you have specified these options, close the Sort [Patient Name] dialog.

Sorting enables you to see patients who were admitted earlier toward the top and patients who were admitted later toward the bottom. It is based on the earliest (minimum) date of admission for the patient, even if they were admitted multiple times. Sorting can be a very useful technique for seeing patterns in the Gantt Chart. Your final view should look something like this:

When plotted on a date axis, the field defining the length of Gantt bars always needs to be in terms of days. If you want to visualize events with durations that are measured in hours or seconds, avoid using the day argument for DATEDIFF because it computes whole days and loses precision in terms of hours and seconds. 
Instead, calculate the difference in hours or seconds and then convert back to days. The following code converts the number of seconds between a start and end date, and then divides by 86,400 to convert the result into days, including fractional parts of the day: DATEDIFF('second', [Start Date], [End Date]) / 86400.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset