How to Overlay Line Graphs in Tableau
Placing two line graphs on the same set of axes is one of the most effective ways to compare trends and spot relationships between different metrics in your data. In Tableau, this is handled using a feature called a "dual-axis" chart. This guide will walk you through exactly how to create and customize overlaid line graphs, turning your separate data points into a single, cohesive story.
Why Overlay Line Graphs? Uncovering Hidden Connections
Before jumping into the “how,” it’s helpful to understand the “why.” When you have two different measures that share a common dimension, like time, putting them on the same chart can reveal insights that you might miss by looking at them separately. It allows you to answer comparative questions at a glance.
Imagine you're a marketing manager. You could overlay:
- Marketing Spend vs. Sales Revenue: See if your increased ad spend last quarter actually led to a corresponding lift in sales. Did the peaks and valleys align, or was there a lag?
- Website Sessions vs. Conversion Rate: Did that viral blog post bring in a ton of traffic? Great. But did that traffic actually convert, or did your conversion rate dip because the visitors weren't your target audience?
- New Users vs. Returning Users: Track your user acquisition efforts against user retention over time. Are you growing sustainably or is your user base churning?
In each case, overlaying the lines provides immediate context. It shifts the analysis from simple monitoring ("Sales went up") to genuine insight generation ("Sales went up right after we launched the new ad campaign").
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Getting Started: Measures and Dimensions
To build anything in Tableau, you need to understand the basic building blocks of your data: Measures and Dimensions.
- Dimensions are qualitative, categorical data. Think of them as the things you want to slice and dice your data by. Examples include dates, customer names, geographic regions, or product categories. In the Tableau Data Pane, they are typically blue.
- Measures are quantitative, numerical data. They are the metrics you want to analyze and aggregate (like summing or averaging). Examples include sales, profit, quantity, and website sessions. In the Tableau Data Pane, they are typically green.
To overlay two line graphs, you need at least one Dimension (which will form your X-axis, usually a date field) and at least two Measures (which will form your two Y-axes).
Step-by-Step: Creating Overlaid Line Graphs with a Dual-Axis Chart
Ready to build? We'll use the classic example of comparing Sales and Profit over time from Tableau's Sample - Superstore dataset. If you don't have this, you can apply the same steps using your own data with a date dimension and two numeric measures.
Step 1: Get Your First Line Graph on the Canvas
The first step is to create a simple line chart with your time dimension and your first measure.
- Connect to your data source.
- From the Data pane on the left, drag your date dimension, Order Date, onto the Columns shelf. Tableau will likely default to segmenting it by YEAR(Order Date).
- Right-click the blue YEAR(Order Date) pill in the Columns shelf and select "Month" from the second section. This will show a continuous monthly view, which is better for trend analysis. The pill should turn green.
- Next, drag your first measure, Sales, onto the Rows shelf.
You should now have a clean, familiar line graph showing your total sales for each month over the entire period of your dataset.
Step 2: Add the Second Line Graph
Now, let’s add the second metric to the view. Drag your second measure, Profit, from the Data pane and drop it onto the Rows shelf, right next to the SUM(Sales) pill.
At this point, Tableau gives you two separate line graphs stacked vertically. We have Sales over time on top and Profit over time on the bottom. It's informative, but we want to combine them into a single view to make direct comparisons easier.
Step 3: Create the Dual Axis
This is where the magic happens. We're going to tell Tableau to combine these two charts using a shared X-axis and two separate Y-axes (one on the left, one on the right).
- Move your cursor over the green SUM(Profit) pill on the Rows shelf.
- Right-click on the pill and select Dual Axis from the dropdown menu.
Just like that, your two charts merge into one. You’ll see the Profit line layered on top of the Sales line, with a new axis for Profit appearing on the right side of your visualization. You'll also notice the Marks card on the left side has changed, now showing controls for "All," "SUM(Sales)," and "SUM(Profit)." This allows you to format each line independently.
Step 4: Synchronize the Axes
This step is absolutely critical for an honest comparison. If you look closely, the axes are scaled independently. The left axis for Sales might go from $0 to $80,000, while the right axis for Profit might only go from $0 to $15,000. This can create a misleading visual where a small change in profit looks just as dramatic as a huge change in sales. You must synchronize them if they share a common unit (like dollars).
- Move your cursor over the right-hand axis (the one for Profit).
- Right-click anywhere on the axis.
- Select Synchronize Axis from the menu.
Now, both axes will use the same scale, providing a true and direct comparison. The chart might look dramatically different, but it's now visually accurate.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Step 5: Customize and Clean Up
The final step is to refine the chart to make it easy to read. You can use the updated Marks card to tweak your visualization.
- Adjust colors: By default, the lines might have similar colors. Click on the "SUM(Sales)" Marks card, then click "Color," and choose a distinct color. Do the same for the "SUM(Profit)" Marks card. Blue and orange are a classic, high-contrast pairing.
- Change chart types: While we have two lines, you could represent one measure as a bar chart to create a combo chart. Just select the Marks card for one of the measures (e.g., "SUM(Sales)") and use the dropdown menu to change it from "Automatic" (which is a line) to "Bar."
- Refine tooltips: Hover over the lines to see your tooltips. You can clean these up by clicking on the Tooltip button on any of the Marks cards and editing the text directly to be clearer and more concise for your users.
- Add Labels: If you want to show the value on the line itself, you can drag the Sales measure to the Label button on the SUM(Sales) Marks card, and do the same for Profit.
Common Troubleshooting and Best Practices
Creating a dual-axis chart is straightforward, but there are a few things to keep in mind to ensure your visualization is effective and not misleading.
- When Not to Synchronize: The only time you shouldn’t synchronize your axes is when you're comparing two measures with completely different scales and units (e.g., Sales in dollars vs. Website Sessions as a count). In this scenario, synchronizing is impossible, but the dual axis is still useful for observing the relationship between the trends. Be extra careful to label your axes clearly in this case.
- Avoid Clutter: Overlaying more than two or three lines can quickly get messy and hard to read. If you need to compare four or five metrics, it might be better to split them into separate charts in a dashboard.
- Mindful Color Choices: Use colors that are easily distinguishable, especially for users who may have color vision deficiencies. Avoid using red and green a lot for up/down trends, as this is a common issue. Tools like Coolors or ColorBrewer can help you select accessible palettes.
- Provide Context: A chart is just a picture without a narrative. Use titles, captions, and annotations in Tableau to explain what the chart is showing and what the key takeaways are. For example, use an annotation to point out the spot where a marketing campaign launched and sales immediately spiked.
Final Thoughts
Mastering the dual-axis chart in Tableau is a fundamental skill that elevates your reporting from basic charts to compelling visual analysis. By overlaying line graphs, you can effectively compare different performance metrics, uncover hidden correlations, and build a much deeper understanding of the forces driving your business.
Building these comparisons in Tableau is a powerful skill, but the process involves multiple clicks, understanding how pills work, and knowing when to synchronize an axis. At Graphed, we’ve focused on simplifying this entire workflow. Instead of going through several steps to configure a chart, you can just ask a question in plain English like, "create a line chart comparing my sales and profit by month." We connect directly to your data sources and instantly build the interactive, real-time dashboard for you, helping you get from data to insight in seconds, not hours.
Related Articles
How to Create Facebook Ads API for Claude Code
Create a Meta Marketing API access token that never expires, using a system user, so Claude Code can pull Facebook ad reports and manage campaigns.
ClickHouse vs Postgres: When to Switch to Columnar
Comparing ClickHouse vs PostgreSQL means matching storage architecture to workload. Row storage wins for transactions. Columnar wins for scan-heavy analytics.
Google Ads for Orthodontists: Get More Booked Consults
Most orthodontic Google Ads campaigns waste money on low-intent searches. The problem is structure, not the platform.