11 Replies Latest reply on Sep 20, 2018 5:07 AM by Olga Labendika

# Combining several measures in one dimension

Hi Everyone,

How can I combine several measures in one dimension?

e.g. I have the following Measures:

• Apples
• Pears
• Oranges

I want to combine them in one Dimension: Fruit Types (with the possibility to filter per fruit type)

How can I do it?

Regards,

Julia

• ###### 1. Re: Combining several measures in one dimension

Are you asking for a way to do this inside Tableau, or in your data source?

Ideally, you'd want the data shaped such that you have a column, like "Quantity", and another column, like "Fruit":

 Quantity Fruit 1 Apple 2 Orange 4 Apple 1 Banana 4 Orange 2 Banana 5 Apple

So, what is your data source?  Are you experienced enough to re-shape the data?

• ###### 2. Re: Combining several measures in one dimension

Hi Matthew,

Sorry for the late reply! I would preferably do it in Tableau itself.

Ideally, I would indeed like to create a dimension: Fruits. The reason for this is that I would like to filter them per fruit type, and have a possibility to calculate percentage of each fruit type towards total Fruits. After that I would like to create a graph with the percentages.

At the moment, when I choose the option to calculate the percentage of different fruit types of total, for each fruit type I get 100%...

And it should be e.g,

apples 30%

oranges 20%

bananas 50%

and not

apples 100%

oranges 100%

bananas 100%

Do you know how to make that possible?

Would be happy if you could help me!!!

• ###### 3. Re: Re: Combining several measures in one dimension

I am not sure how you'd create a dimension called "Fruit" without reshaping the data.  If we could refer to "Measure Names" or "Measure Values" in calculations, then this would be possible.  Then, we could write something like: IF [Measure Names]="Apples" then "Apples"...

However, we cannot do this.  So, in your workbook I simply calculated each % of total manually by creating calculated fields like: Apples %: sum(Apples) / (sum(Apples)+sum(bananas)+sum(oranges)) And used these calculated fields to represent your percentages on a typical bar chart.  The percentages are a bit different from what you were expecting... but I believe they are correct. Let me know if this is acceptable.

The resulting view is:

• ###### 4. Re: Combining several measures in one dimension

Hi Julia,

What I have concluded by your query is that you want to calculate the % of total for each fruit by selecting a fruit from filter. If answer is yes then create a parameter like below: -

then create a calculated field with sum of all the fruits(I named it as "Total Fruits") : -

[Apples]+[bananas]+[oranges]

Create another calculated field with following formula: -

if [Choose Fruit Type]=='Apples' then sum([Apples])/sum([Total Fruits])

else if [Choose Fruit Type]=='Bananas' then sum([bananas])/sum([Total Fruits])

else if [Choose Fruit Type] == 'Oranges' then sum([oranges])/sum([Total Fruits])

end end end

Put this in worksheet & change the datatype to %. Now show your parameter. Now you will get % of each fruit type by total & when you change the values in parameter you can find the changes in your value.

If this is not your requirement, let me know.

Warm Regards,

Prashant Sharma - India | LinkedIn

1 of 1 people found this helpful
• ###### 5. Re: Combining several measures in one dimension

Prashant's parameter extends what I set up, so you can filter on Fruit Types as well--I missed that part. Hopefully, you'll be able to get what you want from this.

• ###### 6. Re: Re: Combining several measures in one dimension

Hi Matthew,

Regards,

Yulia

• ###### 7. Re: Re: Combining several measures in one dimension

I tried to follow your steps but unfortunately didn't manage to build a view (stacked bar). Do you know how to make it possible?  Please find attached the file with the results.

Regards,

Julia

• ###### 8. Re: Re: Re: Combining several measures in one dimension

Hi Julia,

I was previously suggested to parameter as you want to filter the dimensions. But now what I have concluded that you want a single stack bar with % contribution of each. So, Created one according to that. Let me know if this is not what you wanted.

Warm Regards,

Prashant Sharma - India | LinkedIn

1 of 1 people found this helpful
• ###### 9. Re: Combining several measures in one dimension

Yes, this is exactly what I wanted. Thank you very much Prashant!

• ###### 10. Re: Combining several measures in one dimension

Glad to know that it helped!

Warm Regards,

Prashant Sharma - India | LinkedIn

• ###### 11. Re: Combining several measures in one dimension

Hi!