Level Up: Custom Labels in Tableau

In today’s Level Up post, we explore creating custom labels in Tableau to suit the values in a field, like making singular and plural variations.

The Level Up series is designed to take Tableau beginners from out-of-the-box functionality to the next level of design and analytics, and features tip and tricks to make your dashboards more professional and polished. Click here to see all posts in the series.

Adding extra text details to your labels in Tableau makes visuals easier to interpret and clearer. But what happens when the text doesn’t work for every single value in your data? This often comes up when you have both singular and plural values. If the label above said “One speak English”, it would seem a lot less credible! In this post, I’ll show you how to use a calculated field to customize the text in your labels.

Create a Calculated Field

The big key here is creating the right calculated field. The calculated field is going to be used to create the changing text phrase, and should be based on the data field that the text will be based on. We’ll use the calculated field as the custom label. Here’s how my calculated field is set up:

In this example, the field I care about is the count of SISStudentID. In my calculated field, I said that if the count of SISStudentID is 1 (that is, there’s only one student), I want the label to say “speaks” instead of “speak”. I could include the rest of my label here, but I really don’t need to – it’s going to be easier to just put in the word that changes, and include the rest in the label.

Add to the Custom Label and Format

Now let’s set up the label.

Change your mark type to text, and add all the fields you want in the label to your text card. In this situation, I’ve included the number of students (count of SISStudentId), the language, and the calculated field that I made in the first step. (I also have Native Language on the color card so that I can color code my labels).

Once you have all the fields you’ll need, click on the “Text” card to open the editing dialog.

Then click the three dots to edit the text.

Arrange the fields you chose in the label in whatever way makes sense for your data. Here I didn’t need any extra words, because my entire phrase was just [number] + [speak/speaks] + [language], but your situation might need some extra words too – for example, I could add the word “students” to my label, like this:

When I add a fixed text element to my label, like “students”, it now shows up in that spot in all my labels. (This is a good example of how this works, but actually wouldn’t be a good idea to use in this situation – because I would need “students” to change to “student” if there was only one student, I’d probably actually include the “student/s” in my calculated field from before.)

So there we go – custom labels in Tableau! When the field only has one student, the label will say “One speaks ….” instead of “One speak…”, giving you bonus points for both style and grammar. (And who doesn’t want that?!)

I hope you found this post helpful! Make sure to check out the rest of the Level Up series before you go.

Let's keep in touch! New tips, tricks, and tutorials are posted about once a week - sign up to get them straight to your inbox!

I don’t spam! Read the privacy policy for more info.

Leave a Reply

Your email address will not be published. Required fields are marked *