Creating Labels in Tableau Which Can Switch Between K and M Units

By: Eric Parker

Pro Headshot.jpg

Eric Parker lives in Seattle and has been teaching Tableau and Alteryx since 2014. He's helped thousands of students solve their most pressing problems. If you have a question, feel free to reach out to him directly via email.

Let me start by saying this, I’m not sure I fully endorse this approach but I wanted to write a blog post to demonstrate a concept. You’ll have to decide for yourself whether this is a good or bad idea for your audience.

I’ve gotten asked by multiple students if it’s possible to create a currency formatted field where the unit at the end of the number can be a K or M depending on the size of the value. Let’s imagine we are working with a chart like this.

142-1.png

The tricky thing about number formatting in Tableau is the default options only allow you to pick one format per field. That means you can pick K or M but not both.

142-2.png

The solution is to create two calculated fields, one for values over a million one for those under, and format them differently. Here’s what this can look like.

This first calculation is for values equal to or greater than $1M (possibly a little lower like $999,500 depending on your data and rounding).

 
142-3.png
 

This field should be formatted with a single decimal place and have a M unit added.

 
142-4.png
 

The next calculation is for values less than $1M.

 
142-5.png
 

This field can be formatted with K units and 0 decimal places.

 
142-6.png
 

Then both calculations can be added to Label on the Marks Card.

 
142-7.png
 

Finally, you can edit the layout of the fields in the Label section of the Marks Card so your end user can’t tell that two different fields are being used for labels.

142-8.png

If you take this approach, remember to clean up those tooltips!

Need help with your own customization? Reach out or book an office hour and we’ll help you get rolling!

Hiding Secondary Columns in an Asymmetric Drill Down (Tableau Set Actions)

Thoughts on Accessing and Visualizing Public Data

0