Tableau Tip : Creating a 100 Mark Unit Chart Inside of a Tooltip

Creating a 100 Mark Unit Chart inside of a Tooltip in Tableau



Tableau 9.3 is almost out, and it’s bringing with it a lot of awesome features and improvements. BUT, it looks like we’re still going to have to wait a little longer for the bomb diggity VIZ IN TOOLTIP feature to be released. All hope is not lost though, there are ways we can “visualize” data in tooltips now, it just takes some creative thinking.
Some readers may already be familiar with how to create visualizations in tooltips thanks to Andy Cotgreave’s post from back in September of 2010.

http://interworks.co.uk/blog/charts-in-a-tooltip/
Tableau supports ASCII Unicode Characters as strings. By using 3 calculated fields, you can create sub-strings of Unicode blocks to mimic a horizontal bar chart.
  1. A calculated field/parameter containing a series of ASCII Unicode Blocks : [BAR]

    ‘▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮’
  2. A Calculated Field that determines the % of Total Value : [% of Coffee Sales]

    ROUND( (SUM(COFFEE SALES) / SUM(SALES)) * 20 )
  3. A Calculated Field that returns a Substring of the Unicode Blocks based on % of Total Value

    LEFT ( MIN([BAR]) , [% of Coffee Sales] )
Bar in Tooltip.png
I’ve used this technique a lot, and it works really well for adding additional context. It can even be used as a way to slowly move heavy Excel readers over to data visualization.
Creating a 100 Mark Unit Chart follows this same basic idea.
Step 1:
Create the Grid of ASCII Characters in a Calculated Field. This example uses a 5 X 20 matrix, but you can use whatever scale you want (You will just need to change the calcs below accordingly).
[100 Mark Unit Chart]
'▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮' + CHAR(10)
+ '▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮' + CHAR(10)
+ '▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮' + CHAR(10)
+ '▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮' + CHAR(10)
+ '▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮'
The CHAR(10) serves as a Line Break, holding the structure of the Matrix. You can press ENTER instead of using CHAR(10), but be aware that pressing ENTER in a calculated field creates Two additional ASCII Characters in your String Field, whereas CHAR(10) only creates One.
Step 2:
Since CHAR(10) creates an additional character each time it is used in the Matrix, we need to create a calculated field to adjust for it. This allows us to get the proper number of characters needed in the Substring calcs used later.
[Adjustment]
IF [Your % of Total Calc] <= 20 THEN 0
ELSE (FLOOR([Your % of Total Calc] / 20))
END
Step 3:
Create the Substring representing [Your % of Total Calc]. This would be the Total number of Units you want to Highlight in your Tooltip.
[Left Mark]
LEFT([100 Mark Unit Chart], ([Your % of Total Calc] + [Adjustment]))
Here we take a LEFT substring of the [100 Mark Unit Chart] by the length of [Your % of Total Calc] + [Adjustment]. For example 23% breaks down as
▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮ + CHAR(10) => 21 Characters in first Row
▮▮▮ => 2 Characters remaining from 23 [Your % of Total Calc] PLUS 1 for the adjustment
=> 23 Marks visible, 24 Marks actual
Step 4:
Create the Substring that represents 100 - [Your % of Total Calc] (The units you don’t want to highlight in the tooltip)
[Right Mark]
RIGHT( [100 Mark Unit Chart], ( 104 - ( [Your % of Total Calc] + [Adjustment] ) ) )
Here we take a RIGHT substring of [100 Mark Unit Chart] by the length of the string ( 104 ) minus [Your % of Total Calc] + [Adjustment].
This is the same as the Step above, except we work from the End string and find the number of characters not represented by [Your % of Total Calc]
Step 5:
Once you have the calcs setup, you just need to place the [Right Mark] and [Left Mark] Calcs side by side in the Tooltip, and color them as you like.
<ATTR(Right Mark)><ATTR(Left Mark)>
2016-03-16 21_19_01-Tableau Public - 100 Mark Unit Chart - Tooltip_Text Mark.png
And that’s it! Now you can have dynamic Unit Charts right there in your tooltip.
TwoTwo.png
Here’s the great news, as you can tell from the image above, this technique doesn’t have to be limited to the tooltip (i.e., it still has a purpose once Viz in Tooltip is released), you can use it on the Text Mark as well. Take for example the image below. The dashboard is actually just one crosstab containing a single Dimension on the Rows Shelf, but we can create the appearance of a 100 Mark Unit Chart.
St Padds.png
Click on the image view in Tableau Public
I hope you enjoyed reading this, and picked up a few tricks along the way. If you have any questions, or need further explanation, please feel free to reach out to me anytime on Twitter (@RodyZakovich) or by email at RodyZakovich@gmail.com

Regards!
Rody Zakovich
Previous
Next Post »
0 Comment