2 Replies Latest reply on Jun 11, 2017 1:33 PM by Steve McManaman

# Compare values and rank them same colum

Hi there,

I kind of new creating dashboards in tableau and I'm struggling a bit. I need to do some work in some election results: I found out the highest share per candidate by state so I can find out the winner per state. Once this done, I ranked the highest and filtered, so I can see the most voted candidate by state. What I need to do now is find the top 10 states per candidate, and here is where the problem comes, as when I filter by candidate, as the percentage i got it by a table calculation (computing by the other candidate) the percentage gets lost.. not sure if was very clear.. but any help here will be much appreciated. I attached the workbook thanks!

• ###### 1. Re: Compare values and rank them same colum

Hi Steve,

There might be actually 2 parts to this problem - (1) Ranking based on the actual vote shares by candidates (rather than just raw vote counts), and (2) As you mentioned, filtering down to a candidate without breaking the % of total.

I've attached a solution that should work for both parts to this problem:

(1) I computed a RANK([Shares vote]) in order to create the suitable rank. Nesting the table calculations actually allows us to still compute each level independently with different Table Calculations: Addressing and Partitioning.  For the [Share votes] we will still compute this across candidates for each state, whereas the RANK() is going to be computed across states for each candidate (since we are now ranking the states rather than the candidates).  I would open up the "Edit Table Calculation" dialog to see how this is done with the field drop down.

2) Rather than Filter we want to enforce the quickfilter like a Hide function.  There's a trick to doing this as a LOOKUP() function against [Candidate]: LOOKUP(MAX([Candidate]),0)

The calculation actually will be handled as a table calculation and if applied as a filter, would effectively hide each candidate rather than filter them out.  This means it only affects what is displayed and not the % of total computed by our [Shares vote] field.

1 of 1 people found this helpful
• ###### 2. Re: Compare values and rank them same colum

Thank you Wilson, this is genius!