For a recent Makeover Monday, I wanted to be able to visually focus on either the positive or the negative aspect of a metric based on the toggle of a parameter. In particular, I wanted to be able to draw attention to the chosen aspect (positive or negative) by way of a bold color and turn the other portion grey without having to set up separate charts or worksheets.
As with many things in Tableau, this ended up being easier than originally thought. It just took a couple of calculated fields and the realization that the same value can be given multiple names.
Here is what the view looked like when I was done. The chart structure doesn’t change (other than the sort of countries) but the same portion of each chart (bar, donut, etc.) takes on a different color depending upon which parameter choice is selected.
But when I placed it on the color shelf I was only able to assign one color to “pos” and one color to “neg”.
Since I knew I didn’t want to create two charts or duplicate the dimension, the main thing I needed to figure out was how to get the positive and negative values to play two roles, i.e. to be both highlighted and not highlighted depending on what parameter value was selected. What solved the conundrum for me was the realization that the values of “pos” and “neg” were arbitrary…understandable and logical, but ultimately arbitrary. I could just as easily have encoded the values as “captain” and “underpants” and the chart would have behaved the same way. With that insight, I determined that I could encode the values one way when the first parameter value was selected and encode them another way when the second parameter value was selected. Like so:
…and to dynamically sort the countries based on either total positive or total negative responses:
I hope this short tutorial proves useful to others. Thanks for reading.