image_pdfimage_print

Here we show how to plot more than one metric on a single vertical axis in Tableau Online. Metrics are called Pills in Tableau, since they are shaped like a pill.

The problem

For the beginner, Tableau Online is frustrating because, when you put two metrics on the rows (horizontal), it draws two charts as the default behavior. Users of Microsoft Excel are used to Excel doing the desired behavior, plotting multiple axes, automatically.

In Part 1 of this tutorial, we did that using a union. Here we do that by taking two data points from a single view. We’ll create charts with:

Generate your data

You can run this Python code to create some data and then run this SQL command to add a revenue column. Or just pick any data that you have and follow these general instructions.

create view revenue as select salesdate, product, quantity, quantity * random() * 10 as revenue from sales;

Plot two data points on left vertical axis

Create a new data source.

Drag the Salesdate to Columns and then change the date from YEAR() to exact date.

This next step is not exactly intuitive. Drag Measure Names onto the Color Mark. Drag the Measure Values to Rows. This creates a legend to the right for each metric and plot each metric on the chart. (That is the frustrating part for beginners as if you drag each metrics onto Rows it makes a separate chart for each metrics.)

You’ll also want to remove SUM(Number of Records) as that’s not too useful, but Tableau Online adds it to the chart automatically. So, scroll down and find it and remove it from here:

The chart now looks like this:

Zoom in for a closer view:

Plot two data points on dual axis

The chart above looks OK. You could change the label Value to Revenue/Quantity. But let’s use another technique and plot one metric on the left axis and the other on the right axis.

So, instead of using Measure Values drag Revenue and Quantity onto Rows.

Tableau makes two charts. So click Sum(Revenue) and then select Dual Axis to make one instead.

The resulting chart is a bit crowded:

So, edit the quantity axis to force values to a range that does not overlap with the revenue range.

Set a fixed range.

Now it’s easier to read:

Zoom in for a closer view.

Automate workflows to simplify your big data lifecycle

In this e-book, you’ll learn how you can automate your entire big data lifecycle from end to end—and cloud to cloud—to deliver insights more quickly, easily, and reliably.


Last updated: 04/23/2020

These postings are my own and do not necessarily represent BMC's position, strategies, or opinion.

See an error or have a suggestion? Please let us know by emailing blogs@bmc.com.

Run and Reinvent Your Business with BMC

From core to cloud to edge, BMC delivers the software and services that enable nearly 10,000 global customers, including 84% of the Forbes Global 100, to thrive in their ongoing evolution to an Autonomous Digital Enterprise.
Learn more about BMC ›

About the author

Walker Rowe

Walker Rowe

Walker Rowe is an American freelancer tech writer and programmer living in Cyprus. He writes tutorials on analytics and big data and specializes in documenting SDKs and APIs. He is the founder of the Hypatia Academy Cyprus, an online school to teach secondary school children programming. You can find Walker here and here.