A splash of colour on your viz can be the difference between a good viz and a GREAT viz, and being able to manipulate colour through calculations, groups, and sets is an invaluable skill in Tableau. Just look at the front page of Tableau Public and imagine everything in greyscale – while it should still work, it just wouldn’t be the same.
Whether we realise it or not, the connection between colour and storytelling on a viz paves a path for the viewer to understand our stories. Whether colour is used to represent dimensions, measures, or patterns within the data, viewers will find a way to connect it to your story – so use this power wisely!
Tableau’s in-built colour options are pretty good out of the box, but if you want absolute control over the colour palette then calculations, groups, and sets will be your best friends to creating complex colour in your viz.
if and case statements are the most powerful functions to dynamically specify how you want your values to be grouped. These statements are a way for Tableau users to reason with the software and specify a value when their conditions are met.
However for larger datasets or when creating many many groups, these statements can quickly become complex! So the best way to create them is to write out what you want done in a sentence format, and then plug the relevant fields into your statement with the help of Tableau’s formula list.
My favourite statements for colouring are if statements, and these select for something to happen IF a certain condition is met. Imagine it as “if x is true then I want a value of y”. Additionally, if statements can be contained within if statements allowing you to vastly increase the specificity of the grouping within a single! Also, if the conditions are not met, then the value will be returned as a null – which is really easy to filter out of Tableau vizzes ?
You can also combine logic calculations with parameters for some dynamic colouring as seen in step 5 of this blog post.
Groups are a great way to assign a single value to specified rows contained within a field. Each dimension or measure is able to contain any number of groups – but the more condensed your data the nicer it will look when visualised! Groups are particularly powerful for text fields due to the search bar that can automatically group anything that matches your search criteria. Groups are also great for visual clusters or outliers – select your points, right click, and place them into a new group. Your new groups can then be added to colour on your marks card for some great effects.
However, any ungrouped data that may be added in the future will be placed into a group called “Other” – so for data that updates, you may want to use Sets.
Sets can dynamically group dimensions based on corresponding dimensions, measures, or parameter values – and is a perfect candidate for data that changes or updates.
A set can be created manually (but without the easy to use search bar in groups), via a condition, or by the top or bottom fields relative to another dimension, measure, or parameter. Sets are powerful in that you can characterise a dimension based on a different dimension or measure, but are limited in that there are only two output values – IN or OUT. More specificity can be added by selecting two sets and right clicking “combine set” to look at the overlap – but will still be limited to two output values.
Below is a table that summarises the strengths and limitations of each grouping method when it comes to colouring your viz – hopefully it’s as helpful for you as it is for me! ?
|Calculations||Can perform the roles of groups AND sets.
Can be combined with groups, sets, and parameters to generate dynamic views
|Calculations can become quite complex when specifying many groups
Calculation errors can be time-consuming to fix
|Groups||User interface makes grouping similar data easy via the search bar
Groups can be created by selecting points within a viz
|Data within a dimension can only belong to a single group
Groups do not update with new data
|Sets||Dynamic grouping method that combines a dimension with another dimension, measure, or parameter value
Can combine sets
Limited to two output values – IN or OUT