Building Gantt Bar Charts

Gantt charts are useful for displaying the duration of events or activities over time. In a Gantt Bar Chart, each separate mark (usually a bar) shows a duration. For example, you could use a Gantt chart to display average delivery time for a range of products. For more information about Gantt bar mark type, see Gantt Bar Mark.
The following exercise walks you through using Gantt charts to show how many days, on average, elapse between order date and ship date. The data is broken out by product category and ship mode. The view displays results on a weekly basis for a three-month period.
  1. Connect to the Sample - Superstore - English (Extract) data source, which is included with Tableau Desktop.
  2. Drag the Order Date dimension to Columns.
    The date is automatically aggregated by year, and column headers are created with labels showing the years in your data.
  3. Right-click the Order Date field on the Columns shelf and choose Week Number:

    The column headers change—the individual weeks are indicated by tick marks because there are too many weeks in a four-year span (208) to show as labels in the view:

  4. Drag Category and Ship Mode dimensions to the Rows shelf, dropping Ship Mode to the right of Category.
    This builds a two-level nested hierarchy of dimensions along the left axis:

    Now we want to size the marks according to the length of the interval between the order date and the ship date. But there are no measures that we can use to capture that interval. However, we can create such a measure by creating a calculated field.
  5. Right-click anywhere in the Data window (on the far left) and choose Create Calculated Field:

    This opens the Calculated Field dialog box. This option is also available from the Analysis menu.
  6. Name your calculated field OrderUntilShip.
  7. Clear any content that may be in the Formula box by default.
  8. Type (or copy) the following formula and click OK:
    DATEDIFF('day',[Order Date],[Ship Date] )
    This creates a custom measure that captures the difference between the Order Date and Ship Date values, in days.
  9. Drag the OrderUntilShip measure to Size on the Marks card.
    The default aggregation for OrderUntilShip is Sum. But we're not interested in adding all the intervals—it makes more sense to average them.
  10. Right-click the SUM(OrderUntilShip) field on the Marks card, choose Measure (Sum), and then choose Average:

    The view is coming along. But there are too many marks squeezed into the view:

    We can make our data more readable by filtering down to a smaller time window.
  11. Hold down the Ctrl key and drag the Week(Order Date) field from the Columns shelf to the Filter shelf.

    By holding down the Ctrl key, you tell Tableau that you want to copy the field to the new location, with whatever customizations you have added, without removing it from the old location.
    A Filter Field dialog box opens. Click Range of Dates and then click Next, to display this dialog box:

  12. Set the range to a three-month time interval, such as 1/1/2012 to 3/31/2012, and the click OK.
    It can be difficult to get the exact date using the sliders—it's easier just to type the numbers you want directly into the date boxes.
  13. Drag the Ship Mode dimension to Color on the Marks card.
    You now have a view that lets you see all sorts of information about the lag between order times and ship times:

    Which ship modes are more prone to longer lag times? Do lag times vary by category? Are lag times consistent over time?
If you publish this view to Tableau Server, you can include Quick Filters that let users interact with the view by varying the time window, or filtering out various categories or ship modes. For more information, see Publishing Workbooks.

1 comment: