
1. Re: How can I have different colors to my Measures on the map?
Simon Runc Sep 3, 2016 5:48 AM (in response to Sophia Messini)hi Sophia,
So we can do this by way of creating a calculated field, which returns '"PASOK", "ND" or "SYRIZA"...and the you can add this to the colour tile, which will colour the map.
Now the exact form of this calculation will depend on the structure/grain of your data...are you able to post a bit of the data here? (either your .twbx, or just an excel with a few hundred rows...if there is anything sensitive in the data just remove those columns, as it is the shape/grain I need to see)

2. Re: How can I have different colors to my Measures on the map?
Sophia Messini Sep 3, 2016 8:34 AM (in response to Simon Runc)Hello Simon,
Thank you for your response,
Here is an example of my data in excel. I want the calculation to measure if the SUM of ΠΑΣΟΚ is bigger than the others ... SUM "ΝΔ" , SUM"KKE" SUM "ΛΑΟΣ" SUM"SYRIZA" the mark must be green.
If the SUM of "ΝΔ" is bigger I want blue
If the SUM of "KKE" is bigger I want red
If the SUM of "ΛΑΟΣ" is bigger I want purple
If the SUM of "ΣΥΡΙΖΑ" is bigger I want Pink
and that calculate must be at every row because I have the results of every local community.
Thank you very much

example elections.xlsx 442.0 KB


3. Re: How can I have different colors to my Measures on the map?
Christopher McKinnish Sep 3, 2016 6:34 AM (in response to Sophia Messini)I would first ask or assume your data has the "Politician" assigned to each record. If so, drag the Politician field to the Color Mark. The set the color pallet to whatever you want. IF this does not help, maybe you can post a sample or your packaged workbook.

4. Re: How can I have different colors to my Measures on the map?
Sophia Messini Sep 3, 2016 8:34 AM (in response to Christopher McKinnish)Hello Christopher,
thank you very much it really worked out . You can see my map here Tableau Public ΕΚΛΟΓΙΚΟΣ ΧΑΡΤΗΣ 2009. But here is in every city and not in local communities which are about 20.000. It would have been easier for me if there was a calculate for this too.
Thank you very much for your help

5. Re: How can I have different colors to my Measures on the map?
Simon Runc Sep 3, 2016 9:19 AM (in response to Sophia Messini)hi Sophia,
So, as always with Tableau there are a few ways to go about this...I've given you one with your original data structure, and one where I have pivoted the data, to have candidate going down the page
So first with the original...
So we need to find the MAX of each of the measures (which in this case is the number of votes for each candidate), as we can only check the max of 2 measures at a time we need to nest the MAX calculation
[Winning Votes]
MAX(MAX(MAX(MAX([ΚΚΕ],[Λαοσ]),[ΝΔ]),[Πασοκ]),[Συριζα])
once we have this we can see which measure is equal to that value (note that if there is an equal first place, the order of the IF statement will determine what colour the city will take)
[Winner]
IF SUM([ΚΚΕ]) = MAX([Winning Votes]) THEN 'KKE'
ELSEIF SUM([Λαοσ]) = MAX([Winning Votes]) THEN 'Λαοσ'
ELSEIF SUM([ΝΔ]) = MAX([Winning Votes]) THEN 'ΝΔ'
ELSEIF SUM([Πασοκ]) = MAX([Winning Votes]) THEN 'Πασοκ'
ELSEIF SUM([Συριζα]) = MAX([Winning Votes]) THEN 'Συριζα'
END
and then you can colour on this field.
The other way I did it was to pivot the data...in general Tableau (being based on database/set theory prefers data like this...although from doing some political Vizes myself, there are times when it's good like this, and others when your original structure is best. I tend to have both, as separate datasources and then blend between the 2)
So first to Pivot the data, I used the function Tableau provides on the connecttodata screen
which gives me the data like this (where I have renamed the columns to candidate and votes)
From here I have used a nested FIXED LoD...the second nesting is just to it brings back a single value for each city
[Winner]
{FIXED [Τμημα]: MAX(IF [Votes] = {FIXED [Τμημα]: MAX([Votes])} THEN [Candidate] END)}
As you'll see we are doing the same check, on MAX, but as the data goes down the page we can do it in one go.
I'm not able to actually map it, as I don't have the City field tableau picks up, but have added the colour to both tables so you can see it's working. I've also, in both tables, added parts of some of the calculations so you can see how it's working.
I would also add that there are other ways too (eg. using table calcs), but these are probably the 'logically' most simple (if not the most efficient, in terms of query time...but on a dataset of this size you can get away with it!!)
Hope that does the trick, and makes sense, but please post back if not.

Colouring Map on Election.twbx 442.0 KB


6. Re: How can I have different colors to my Measures on the map?
Sophia Messini Sep 3, 2016 10:41 AM (in response to Simon Runc)Thanks for your time Simon,
I will try it and I will come back to inform you
Sophia