Learn Tableau IF Statement Labelling in Tableau

IF Statement Labelling in Tableau

Here’s a quick tip that lets you dynamically group up and label values within a dimension within Tableau, using a calculated field. It’s handy when you want to group a dimension with lots of names, based on a set of rules. E.g. In the example below were grouping up all rows that contain Burger and another for Sausages, despite lots of variations in their names. This grouping can make it simpler to analyse data, whilst preserving the granular data below.

You could do this manually but that takes time, exposes you to human error and you’d have to constantly update things as the data grows.

Simply write an IF CONTAINS and ELSE IF CONTAINS calculated field to do this. I’ve made a template below, saving you from writing it from scratch. Simply:

  1. Make a copy
  2. Add in the relevant info
  3. Paste the equation column into a new calculated field.


It’s probably best to have a worksheet set up, filtered to the Other label, so you can easily see which fields, old and new, don’t fit into your logic.

And you’re all set! I’ve used this technique a lot when grouping up data fields, like in the examples below:
23 Game GrumpsQi score button 09-Global-Airplane-Crash-DataNuclear Detonations 1945-2009

I hope this helps you in your work. If you have any questions or tips you’d like to share, please get in touch. I’d love to hear about them.

3 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Follow

Tableau PublicYouTubeTwitterFacebookLinkedInInstagramEmail Newsletter

Latest Articles

Time Saver Tool v2.0

Have you ever discovered a way to speed up a process but cannot convince others to do it? Felt like you don't...

SG Tableau User Group Oct 2020

The SG Tableau User Group just wrapped up it's October virtual livestream event, which you can now watch on YouTube here. It...

Find insights beyond the summary stats (w/ data viz)

In this video we will see how summary stats can be misleading and the importance of data viz to easily dig deeper into the numbers beneath them.

Data Studio Community Livestream | Jun 2020

Welcome to the first Data Studio Community Livestream - you'll see 4 speakers covering a wide variety of topics, which should help any and...

That’s a Moiré! w/ Tableau animations

My brother runs a high end silk screen printing business in London, Make-Ready, and every time I...