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?