March 22, 2017
Workout Wednesday: Highlight a TreemapEmma was at it again this week with her little tricks! This week's workout was to rebuild this treemap. You can see all of the requirements on Emma's blog.
The requirements are pretty straight forward:
- The treemap should be segmented by Product Category and Product Sub-Category with Sales as the size of each part.
- The Sales value should also colour each segment of the treemap as a gradient (she used blue with the highest sale being the lightest blue).
- You should be able to highlight a segment of the treemap with a different colour (in orange). The part highlighted should be able to be changed by the end user.
I must admit that don't know how to build treemaps in Tableau, so I took the easy way out and used Show Me for I think the first time in quite a while. That was easy!
I had an idea straight away for how to create the necessary calculation for coloring the sub-categories. This, however, resulted in my colors being shaded from lightest to darkest, that is, the sub-category with the largest sales was darkest. Emma's has the darkest color as the least sales, so I knew I wasn't done. This is what you see in the method 1 tab below. Method 1 uses a single calculation, but it won't work if any sub-category has negative sales. Though the treemap would crap out too.
Method 2 matches Emma's exactly. This requires two calculations and understanding when you need to make a field an attribute and when you need to make a field discrete. This method colors the sales from darkest to lightest, with the sub-category with the largest sales being the lightest color.
Method 3 is similar to method 2 in that it requires two fields on the color shelf. However, this colors sales from lightest to darkest, with the sub-category with the largest sales being the darkest color.
Good challenge Mrs. Emma!