Dueling with dual axes

Charts with dual axes can be a mixed blessing. Adding an additional axis can help with comparison purposes. Comparison is one of the essential tools of analyzing data. You can often hear it expressed in user questions, such as how does that figure compare to last year's? Or where are we in relation to our target?

On the other hand, dual axes are best used where the viewer really understands the data. They can be very misleading. For example, if we have units on one axis and currency on another, the chart can be hard to understand. Further, more if the axes are contracted whereby they don't start at zero, or only show a band of the data, then the naïve user may find it misleading. Normally, due to these issues, dual axes charts are best avoided where people don't understand the data very well. This is particularly the case for a dashboard, where people are expecting to pick up information very quickly.

In Tableau, however, the use of dual axes can be very useful to display the same data in different ways in order to enhance the message of the data. In this recipe, we will look at using dual axes charts as another neat trick for visualizing data.

Getting ready

For the exercises in this recipe, we will build on the existing Chapter 6 dashboard. We don't need to add in any more data for now.

How to do it…

  1. Drag FullAlternateDateKey onto the Columns shelf.
  2. Remove the header by right-clicking on the blue pill and deselecting Show Header. You can see an example in the following screenshot:
    How to do it…
  3. Drag EnglishProductCategoryName onto the Rows shelf.
  4. Drag SalesAmount onto the right-hand side of EnglishProductCategoryName on the Rows shelf. You should get line charts now.
  5. To change the lines to make them gray for all the product categories, drag EnglishProductCategoryName onto the Color button and click on the right-hand side downward-facing arrow and select the Edit Colors… option. Here is an example in the following screenshot:
    How to do it…
  6. Click on each category in turn and select the color to be gray. You can see an example in the following screenshot:
    How to do it…
  7. You can see that Bikes has a much higher sales amount than Accessories or Clothing. The sales amount value for Bikes is a behemoth next to the other categories, which unfortunately means that we cannot see the patterns in the data for these categories. To solve this problem, we need to change the axes so that they are synchronized and we can see the patterns. Right-click on the SalesAmount y axis and choose the option Edit Axis.
  8. In the Edit Axis dialog box that appears, deselect the Include Zero checkbox and select the option Independent axis ranges for each row or column. Then, remove SalesAmount from the Title textbox and deselect Automatic. Then, we click on Apply and OK, as shown in the following screenshot:
    How to do it…
  9. Next, click on the SalesAmount green pill and uncheck the option Show Header.
  10. Finally, go to the Columns shelf, click on Year(FullSalesAmount), and select Discrete.
  11. Right-click on EnglishProductCategoryName and deselect Show Header.
  12. Right-click on SalesAmount and select Create Calculated Field.
  13. We will create a calculated field that calculates whether the latest sales amount is greater than the average amount of sales for each row. In the Name field of the Calculated Field editor, type SalesAmountComparison.
  14. In the Text field of the Calculated Field editor, type the following formula and click on OK:

    ZN(SUM([SalesAmount])) - Window_AVG(SUM([SalesAmount]))

  15. On the Marks shelf, click on SUM(FullSalesAmount) and drag SalesAmountComparison onto the Color button.
  16. Let's use color to signify the result. We will categorize the color into three types: red for below average, gray for close to the average sales amount, and blue for greater than the average sales amount. On the Color mark for SalesAmountComparison, select Edit Colors… from the right-hand side downward-facing arrow button.
  17. Select Stepped Color and type the number 3 to represent three steps. Instead of the green color, click on the green box at the left-hand side of the green bar and a color dialog box will appear. Select blue. Then, select the Reversed option and click on OK. You can see the result in the following screenshot:
    How to do it…
  18. Finally, hide the field name for the columns by selecting FullDateAlternateKey in the visualization and reselecting Show Header.
  19. The result so far should appear as shown in the following screenshot:
    How to do it…
  20. Rename the sheet Topic 1 Color Sparkline.
  21. Duplicate the sheet by going to the tab name, right-clicking on it, and selecting Duplicate Sheet.
  22. Rename the sheet Topic 1 Color Sparkline.
  23. Go to the Show Me tab and select the table visualization.
  24. Drag EnglishProductCategory onto the Rows shelf.
  25. Drag Year(FullDateAlternateKey) onto the Filters shelf and filter by Years so that only data for the year 2008 is showing.
  26. Drag Latest Sales Amount onto the canvas area to show the numbers.
  27. On the Marks shelf, drag SalesAmountComparison onto the Color button.
  28. Click on the Color button and choose the option Edit Colors….
  29. On the Edit Colors dialog box, choose the Stepped Colors option and enter the number 2.
  30. Choose the Reversed option.
  31. Select the left-hand side square box, and in the color dialog box, select gray and click on OK.
  32. Select the right-hand side square box in the color dialog box, select royal blue, and then click on OK. You can see the final settings in the following screenshot:
    How to do it…
  33. Click on SUM(SalesAmount) and sort in descending order.
  34. The resulting visualization should look like the following screenshot:
    How to do it…
  35. Now, let's put them together in a dashboard. To create a new dashboard, right-click on the name tab at the bottom and select New Dashboard.
  36. On the dashboard sheet, select the worksheets Topic 1 Color Sparkline and Topic 1 Color Average and put them next to each other on the canvas.
  37. On the dashboard, hide the title for the Topic 1 Color Sparkline worksheet by clicking on the downward-facing arrow on the right-hand side and deselecting Title.
  38. Now, hide the title for the Topic 1 Color Average worksheet by clicking on the downward-facing arrow on the right-hand side and deselecting Title.
  39. Resize the rows on each worksheet so that they match nicely.
  40. Navigate to Format | Shading.
  41. To add banding, go to the sheet tab on the format shading series of options that appear on the left-hand side of the screen. Select Row Banding and move the Band Size slider until it is halfway along the slider.
  42. Navigate to Format | Lines. Set each of the lines to None.
  43. Now click on the right-hand side visualization in the dashboard and then select the Lines option from the Format menu. In each of the Rows options, select None.
  44. Now go back to the Format menu item and select the Borders option. On the Sheet menu item, select None for the Row Divider option.
  45. Your completed dashboard should appear as shown in the following screenshot:
    How to do it…

How it works…

Dual axes can be difficult to interpret, particularly if each axis is showing different measurements. However, here, dual axes can help us to create a visualization. Using a dual-axes chart here allows us to set the size and color of the circle highlights and the line chart independently.

In this recipe, we used a ZN formula. The ZN formula is used when you want to replace a zero with null values. We saw the impact of null values in an earlier chapter, and this is one option for us.

There's more…

Tableau has some great functionality which means that you can have fun with the appearance of sparklines as well as provide more information. For example, you could use the Line End option for the label and use advanced editing on the text label to format in order to provide more detail for the dashboard users.

..................Content has been hidden....................

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