Angela
Angela

Reputation: 235

How do I plot one measure per axis in Tableau?

I have a problem that I have reduced to its essence with the following CSV file. Imagine we're a company that sells potatos and apples, and each customer is assigned a potato-class and an apple-class.

Contents of the CSV

What I want is to plot the sales according to class - so apple sales by apple class and potato sales by potato class, in one diagram. Dragging all the measures into a workheet, I get this:

4x4

So I would like an overlay of the top left and bottom right classes. If I combine everything into one diagram via dual axis, I get this:

One_diagram

So Tableau is plotting potato sales and apple sales on both the potato and the apple class axis, creating four dots per class where I want two.

Does anyone have an idea on how to basically assign one measure to one axis instead of both measures to both axes? (Hiding the "wrong" dots would also be fine).

Also, I realize that pivoting the dataset to have fields "sales", "class" and "product" would solve the problem, but reality is of course far more complicated than this toy example and it's just not feasible.

Thanks!

Upvotes: 1

Views: 58

Answers (1)

Alex Blakemore
Alex Blakemore

Reputation: 11919

You'll likely have an easier time if you reshape your data first, say to have the following columns "Customer,Item,Class,Amount" -- so each row in your original data set would yield 2 rows in the transformed version of your data set. Tableau Prep can make those types of transformations easy (and repeatable), but it is possible to do something similar in Tableau Desktop alone (using a self-union and some calculated fields).

So the first 2 lines might be:

Customer,Item,Class,Amount
1,"Apple",1,2
1,"Potato",1,4

Either way make sure Class is treated as a dimension in Tableau.

Data wranglers often call this a tall format instead of a wide format.

Upvotes: 1

Related Questions