Dual-axis charts, also known as combination charts, allow you to compare two different measures on the same graph. This is particularly useful when you want to visualize relationships between two variables that have different scales or units of measurement. In this section, we will cover the following:
- Understanding Dual-Axis Charts
- Creating a Dual-Axis Chart
- Synchronizing Axes
- Customizing Dual-Axis Charts
- Practical Example
- Exercises
- Understanding Dual-Axis Charts
Dual-axis charts are powerful tools for visualizing data because they allow you to:
- Compare two different measures.
- Use different chart types for each measure (e.g., bar and line).
- Highlight relationships and trends between the measures.
Key Concepts
- Primary Axis: The main axis on which the first measure is plotted.
- Secondary Axis: The additional axis on which the second measure is plotted.
- Synchronization: Aligning the scales of the primary and secondary axes to make comparisons easier.
- Creating a Dual-Axis Chart
Step-by-Step Guide
- Connect to Data Source: Open Tableau and connect to your data source.
- Drag Measures to Rows: Drag the first measure to the Rows shelf.
- Drag Measures to Columns: Drag the second measure to the Columns shelf.
- Create Dual-Axis: Right-click on the second measure on the Rows shelf and select "Dual-Axis".
- Synchronize Axes: Right-click on the secondary axis and select "Synchronize Axis".
Example
Let's create a dual-axis chart to compare Sales and Profit over time.
1. Connect to the Sample - Superstore data source. 2. Drag the `Order Date` field to the Columns shelf. 3. Drag the `Sales` field to the Rows shelf. 4. Drag the `Profit` field to the Rows shelf, next to the Sales field. 5. Right-click on the `Profit` axis and select "Dual-Axis". 6. Right-click on the secondary axis (Profit) and select "Synchronize Axis".
- Synchronizing Axes
Synchronizing the axes ensures that both measures are on the same scale, making it easier to compare them. This is particularly important when the measures have different units or scales.
How to Synchronize Axes
- Right-click on the secondary axis.
- Select "Synchronize Axis".
- Customizing Dual-Axis Charts
Changing Chart Types
You can use different chart types for each measure to make the visualization more effective.
- Click on the Marks card for the first measure and select the desired chart type (e.g., Bar).
- Click on the Marks card for the second measure and select a different chart type (e.g., Line).
Formatting Axes
- Right-click on the axis you want to format.
- Select "Format" and adjust the settings as needed.
Adding Labels and Tooltips
- Drag the desired fields to the Label and Tooltip shelves on the Marks card.
- Customize the labels and tooltips as needed.
- Practical Example
Let's create a dual-axis chart to compare Sales and Profit over time using different chart types.
Step-by-Step Guide
- Connect to Data Source: Open Tableau and connect to the Sample - Superstore data source.
- Drag Order Date to Columns: Drag the
Order Date
field to the Columns shelf. - Drag Sales to Rows: Drag the
Sales
field to the Rows shelf. - Drag Profit to Rows: Drag the
Profit
field to the Rows shelf, next to the Sales field. - Create Dual-Axis: Right-click on the
Profit
axis and select "Dual-Axis". - Synchronize Axes: Right-click on the secondary axis (Profit) and select "Synchronize Axis".
- Change Chart Types:
- Click on the Marks card for Sales and select "Bar".
- Click on the Marks card for Profit and select "Line".
- Format Axes: Right-click on the axes and select "Format" to adjust the settings.
- Add Labels and Tooltips: Drag the desired fields to the Label and Tooltip shelves on the Marks card.
Example Visualization
1. Connect to the Sample - Superstore data source. 2. Drag `Order Date` to the Columns shelf. 3. Drag `Sales` to the Rows shelf. 4. Drag `Profit` to the Rows shelf. 5. Right-click on the `Profit` axis and select "Dual-Axis". 6. Right-click on the secondary axis (Profit) and select "Synchronize Axis". 7. Click on the Marks card for Sales and select "Bar". 8. Click on the Marks card for Profit and select "Line". 9. Right-click on the axes and select "Format" to adjust the settings. 10. Drag the `Sales` and `Profit` fields to the Label and Tooltip shelves on the Marks card.
- Exercises
Exercise 1: Create a Dual-Axis Chart
Task: Create a dual-axis chart to compare Sales and Quantity over time.
- Connect to the Sample - Superstore data source.
- Drag
Order Date
to the Columns shelf. - Drag
Sales
to the Rows shelf. - Drag
Quantity
to the Rows shelf. - Right-click on the
Quantity
axis and select "Dual-Axis". - Right-click on the secondary axis (Quantity) and select "Synchronize Axis".
- Change the chart type for Sales to Bar and for Quantity to Line.
- Format the axes and add labels and tooltips.
Solution:
1. Connect to the Sample - Superstore data source. 2. Drag `Order Date` to the Columns shelf. 3. Drag `Sales` to the Rows shelf. 4. Drag `Quantity` to the Rows shelf. 5. Right-click on the `Quantity` axis and select "Dual-Axis". 6. Right-click on the secondary axis (Quantity) and select "Synchronize Axis". 7. Click on the Marks card for Sales and select "Bar". 8. Click on the Marks card for Quantity and select "Line". 9. Right-click on the axes and select "Format" to adjust the settings. 10. Drag the `Sales` and `Quantity` fields to the Label and Tooltip shelves on the Marks card.
Exercise 2: Customize a Dual-Axis Chart
Task: Customize the dual-axis chart created in Exercise 1 by adding a reference line for average Sales and changing the color of the Quantity line.
- Add a reference line for average Sales.
- Change the color of the Quantity line to red.
Solution:
1. Right-click on the Sales axis and select "Add Reference Line". 2. In the Reference Line dialog box, select "Average" and click OK. 3. Click on the Marks card for Quantity. 4. Click on the Color shelf and select red.
Conclusion
In this section, you learned how to create and customize dual-axis charts in Tableau. You now know how to:
- Create a dual-axis chart.
- Synchronize axes.
- Customize chart types, axes, labels, and tooltips.
These skills will help you create more effective and insightful visualizations by allowing you to compare multiple measures on the same graph. In the next module, we will explore using parameters to add interactivity to your visualizations.
Tableau Course
Module 1: Introduction to Tableau
- What is Tableau?
- Installing Tableau
- Tableau Interface Overview
- Connecting to Data Sources
- Basic Data Types and Structures
Module 2: Basic Visualization Techniques
- Creating Your First Visualization
- Using Marks and Cards
- Building Basic Charts
- Filtering Data
- Sorting and Grouping Data
Module 3: Intermediate Visualization Techniques
- Using Calculated Fields
- Creating Dual-Axis Charts
- Using Parameters
- Creating Maps
- Using Table Calculations
Module 4: Advanced Visualization Techniques
- Advanced Chart Types
- Using LOD Expressions
- Creating Dashboards
- Dashboard Actions
- Storytelling with Data
Module 5: Data Preparation and Transformation
Module 6: Advanced Analytics
Module 7: Performance Optimization
- Optimizing Workbook Performance
- Extracts vs Live Connections
- Reducing Load Times
- Performance Recording
- Best Practices for Performance
Module 8: Tableau Server and Online
- Introduction to Tableau Server
- Publishing Workbooks
- Managing Permissions
- Scheduling Extracts
- Collaborating with Tableau Online