3 Replies Latest reply on Jul 12, 2016 2:02 AM by Siraj Samsudeen

# Calculation within dimension

Hi everyone,

I am still pretty new to Tableau and am struggling massively with calculations.

I even lack the precise terminology to explain what I aim to achieve.

In the attached workbook (dealing with election data for Australia in 2016) I want to show the share of votes that a certain party won per polling station.

The data lists all parties for each polling station and the total number of votes each party won.

I want to calculate something like that:

[Number of votes for "The Greens" per polling station] / [Total number of votes per polling station] = 10%

Then I want to map the share of a specific party for each polling station (ranging from around 0% to around 60% for The Greens for example) and show which polling stations ended up over a specific threshold (let's say 25% of votes for The Greens).

I don't know how to do calculations with one specific party as in the dimensions field only a "Party Name" pops up.

What do I need to type into the calculations field to achieve my desired outcome?

Any help on this will be highly appreciated - I tried looking this up in older forum posts but I just don't know what to call the sub-dimensions (like "The Greens") of a dimension (Like "Party Name").

Thank you so much

Simon K

• ###### 1. Re: Calculation within dimension

Hi Simon,

I understood that you are struggling to communicate your problem. But no worries, we are here to help and your explanation makes the problem clear. Let me see whether I can help you.

When you want to create a calculation that filters only a specific value of a Dimension (Green is one value of the Party Name Dimension), you have to create a calculated field like this below. Here I am just checking whether the Party Name is "The Greens" and if yes, I am adding up the Ordinary Votes. Otherwise, this equation returns a NULL which gets ignored when the SUM aggregation is applied when you drag this field to the view.

Step 1: Then I create another calculated field to create the ratio - here I am doing a SUM on the Numerator and on the Denominator as we want to sum up all the values for the Deno & Nume and then do the division.

Step 2: Now you want to calculate this value by Polling Station. Looking at your data set, I do not see Polling Station. I guess you mean 'Polling Place'. Hence, I have created a simple report - would this help you to solve your problem?

Step 3: 1 of 1 people found this helpful
• ###### 2. Re: Calculation within dimension

Wow, thank you so much! That was exactly what I was after!

Just to clarify the terminology, in the example above "Polling Place" is called dimension and "The Greens" is one value of this dimension?

• ###### 3. Re: Calculation within dimension

Hi Simon, Glad to know your problem is resolved.

Yes, the Polling Place is the Dimension and “The Greens” is one of the values of the Dimension. Tableau purists would like to call “The Green” a member of the Dimension. For me, both convey the meaning.

To make it easy for you to understand, if you have this data in Excel, you would call “Polling Place” the column name and “The Greens” the value of a column. Here, the equivalent of a column name (metadata) is Dimension Name (in short, Dimension) and the equivalent of the column value (actual data) is Dimension Member or Dimension Value (or simply, a value). I hope this clarifies.