Have you ever wanted to add a small visual cue to help convey values in a table or tooltip?

One technique I like combines custom number formatting with Unicode icons. It's not the only way to add icons to a viz, and in some cases the limitation of not being able to color the icons by value outweighs the ease-of-use advantage, but this is still one my favorite 30-second tips

Custom Number Formatting and Unicode Icons

Below is an example of this technique that shows the year-over-year percent change in sales by customer segment. The left table uses Tableau's standard formatting for percentages. The right table draws attention to the declining segments with a "down" icon.

To insert the triangles, click the measure pill—in this example, SUM(Sales)—and select Format.

In the Numbers drop-down box, select Custom, then copy and paste the down icon in the Format box.

 

Custom formatting in Tableau is based on Excel's custom format pattern, in which you specify different formats for positive, negative, and zero values by separating the formats with a semicolon.

While you can find many good references on the web that describe the formatting options, Tableau gives you all the help you'll need.  If you select one of the built-in formats—for example, percentage with 0 decimal places—Tableau will populate the custom format box with the previously selected number format—in this example, 0%. Just remember to use semicolons to add formatting for negative and zero values. 

Unicode Characters

I added the Unicode characters by copying and pasting the character from a reference page like the one below. When you copy a character, you're copying the underlying multi-byte code point. In an ideal world, all fonts, web browsers, and operating systems would map a particular code point to the same character. In practice, this doesn't always happen. When browser or OS support is missing for a character, you’ll see a ? (a question mark).

I've tested the below characters on Windows and Apple iOS, but it's still a good idea to keep an eye out for incompatibilities. (See http://jimw.me/tabicons)

Tooltips and Color Icons

Custom formatting also applies to values in tooltips. You can even add color icons by creating separate calculated fields for the positive and negative icons. 

Add both of these fields to the Tooltip button on the worksheet.


Next, change the custom formatting for Sales % Change to use 0% for both positive and negative values.

Finally, add a tooltip with the PosIcon and NegIcon fields next to each other and change the text color. I'm using the traditional green for positive and red for negative, but you can use any colors you like, of course. Because the fields have mutually exclusive conditions, only one will be shown in the tooltip box.

The result: is color-coded icons in the tooltips.

Legends

You can also use Unicode characters to build your own legends. Here's an example where I added a legend subheading that helps readers who are unfamiliar with bullet charts to understand what the shading and lines represent. Like tooltips, chart titles are text boxes, which allows you to use different colors in the same string.

Want More?

If you want to know more about Unicode, check out Joel Spolsky's blog post, The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!). For a library of Unicode characters, the best I’ve found is The Unicode Consortium’s code charts.

Link to this page
  • No labels