Chapter 65. How to Dynamically Format Numbers

One of my favorite tricks in Tableau is to provide the ability for myself and my end users to choose which dimension or measure is displayed on a view (see Chapter 64). This user experience is provided by setting up a parameter with the options and then creating a calculated field that tells Tableau what to display when each option is selected. The parameter approach to dimension and measure display has two huge benefits: (a) it puts the power of the analysis into the hands of end users (which allows discovery), and (b) it saves valuable real estate on a dashboard by displaying only what is selected.

However, there is one big drawback to dynamically displaying measures: number formats. To produce the user experience described, a calculated measure must be created, and calculated measures can only have one default number format. This is problematic if you are allowing your end users to choose between measures that have varying number formats such as integer, percent, and/or currency. Having one shared number format across all of the measure options is usually not a deal breaker, but wouldn’t it be great if you could pick a different number format for each number?

This chapter shares how to dynamically format measures in Tableau. We will be using the Sample – Superstore dataset to dynamically format the Quantity, Discount, and Sales measures into integer, percent, and currency formats, respectively.

How to Dynamically Format Numbers ...

Get Practical Tableau now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.