Chris
Chris

Reputation: 343

Dual axis with three or more measures

I am using Tableau version 9.3. I want my bar graph to be my Contacted measure and add multiple lines for other measures in one visualization. How can I overlay multiples lines (measures) on my graph?

Visual

Upvotes: 0

Views: 1474

Answers (1)

devlin carnate
devlin carnate

Reputation: 8591

One way to do this is to transform your data. Your data is likely structured something like this:

Walletshare | Cat Acquisition   |Balance Growth     |Early Engagement   |Contacted
------------|-------------------|-------------------|-------------------|-----
Blue        |4144961            |14203659           |20588              |20000000
Orange      |1683077            |6199327            |11285              |9000000
Green       |1106604            |4180726            |7917               |7000000
Red         |1833729            |7387504            |24075              |16000000

So, your measures are all in separate columns. If you transform your data to this structure:

Type                |Walletshare Cat        |Amount
--------------------|-----------------------|-----
Acquisition         |Blue                   |4144961
Acquisition         |Orange                 |1683077
Acquisition         |Green                  |1106604
Acquisition         |Red                    |1833729
Balance Growth      |Blue                   |14203659
Balance Growth      |Orange                 |6199327
Balance Growth      |Green                  |4180726
Balance Growth      |Red                    |7387504
Early Engagement    |Blue                   |20588
Early Engagement    |Orange                 |11285
Early Engagement    |Green                  |7917
Early Engagement    |Red                    |24075
Contacted           |Blue                   |20000000
Contacted           |Orange                 |9000000
Contacted           |Green                  |7000000
Contacted           |Red                    |16000000

Then you can create a calculated formula to aggregate the Contacted Total and the Total for Types Other than Contacted. These will be the two measures in your dual axis.

Contacted Total:

IF [Type] = "Contacted" THEN Amount ELSE 0 END

Total for Types Other than Contacted:

IF [Type] = "Contacted" THEN 0 ELSE Amount END

Then, you'll want to distinguish your lines for the Total for Types Other than Contacted by Type, however, you don't want to show a line for Contacted because that's you measure for the bar chart. To hide the Contacted in the bottom chart (before you do the dual axis), do:

Create a calculated formula Type Contacted, which is:

Type = "Contacted"

Put that formula on the Size shelf in the line chart. This will add a Size legend to your viz, with values True and False. Right click on True and select Hide. Then move the Type Contacted formula from the Size shelf to the Details shelf.

Then create a calculated formula Type Other Than Contacted, which is:

IF Type <> "Contacted" Then Type END

Add that to the Color shelf in the line chart. You will get 3 lines (Acquisition, Balance Growth and Early Engagement).

Then do the dual axis to overlay the line chart on the bar chart.

viz

Upvotes: 1

Related Questions