7 Replies Latest reply on Nov 10, 2016 7:32 PM by Sherzodbek Ibragimov

# How can I create a side by side bar chart with 3 measures where each has a different label

Hi,

I've got what seems a simple requirement but cannot find how to achieve it.  I want to create the equivalent of a triple-axis chart (which I know we can't do) where I can assign a different label to each of the different measures.

Attached is sample 9.2 workbook where I'm trying to create a side by side bar chart by state with the measures "Sum of Number of Sales", "Sum of Number of Returns", "Sum of Profit", and the labels for each of the measures should be "Avg. Retail Price", "Sum of Returns Freight", "Sum of Donations on Profit" respectively.

I've tried to create a calculated field, to use as the label, but as each row contains data for each measure I can't find a criteria to display a different labels, e.g., something like the calc below won't work:

IF SUM([Number of Sales]) > 0 THEN AVG([Retail Price])

ELSEIF SUM([Number of Returns]) > 0 THEN SUM([Return Freight])

ELSEIF SUM([Profit]) > 0 THEN SUM([Donations on Profit])

END

I can create a dual-axis chart that'll enable me to have a different label for each measure, but my requirement is to show 3 measures, and obviously there's no triple-axis option.

Sheet 1 (see below) shows what the labels for each measure should look like (but this isn't the correct format):

Sheet 2 (below) shows how I want to represent the data (but the labels for Number of Returns and Profit are not correct, as each measure within the state has the same value which isn't what I need):

Any help welcome.

Cheers,
Charlie.

• ###### 1. Re: How can I create a side by side bar chart with 3 measures where each has a different label

Hi Charlie,

Is this is what you are looking for ;

• ###### 2. Re: How can I create a side by side bar chart with 3 measures where each has a different label

Charlie

Is that what you wanted as seen below:

So, I have to pivot 3 fields:

- "Number of Sales", "Number of Returns", "Profit"

THEN YOU WILL GET :

Use below formula

-

IF ATTR([Pivot Field Names])='Number of Sales' THEN AVG([Retail Price])

ELSEIF ATTR([Pivot Field Names])='Number of Returns' THEN SUM([Return Freight])

ELSEIF ATTR([Pivot Field Names])='Profit' THEN SUM([Donations on Profit]) END

Then bring this formula to the label and it will take care of it. I hope it helps.

Sherzod

2 of 2 people found this helpful
• ###### 3. Re: How can I create a side by side bar chart with 3 measures where each has a different label

Hi Sherzod,

Thanks for that, it does work for excel (and is useful to know), however my actual datasource is not excel, but is a SAP Hana database and Tableau doesn't let me pivot for that datasource.

I wonder if there's any other way to do this, as it seems a simple requirement?   Any other suggestions welcome.

@Tharashasank thanks for the suggestion, but adding the values for each measure to the chart wasn't what I was trying to do.

Thanks,

Charlie.

• ###### 4. Re: How can I create a side by side bar chart with 3 measures where each has a different label

Charlie,

I am not really sure, but I will definitely try New Custom SQL to get the result you want. Have you tried it yet?

• ###### 5. Re: How can I create a side by side bar chart with 3 measures where each has a different label

Hi Sherzod,

I didn't use custom SQL, but expanded on your previous pivot suggestion and altered the source data slightly to provide it in a format which would enable me to produce the chart as required.

It still seems a product limitation, as if I couldn't change source data I'm not sure I'd have been able to achieve this.

Charlie.

• ###### 6. Re: How can I create a side by side bar chart with 3 measures where each has a different label

Charlie

You should try to use Custom SQL since it doesn't change your data structure at all. It is just reshaping your your data structure to pivoted structure without changing your structure. I hope it helps.

Sherzod

• ###### 7. Re: How can I create a side by side bar chart with 3 measures where each has a different label

Charlie,