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:
- Make a copy
- Add in the relevant info
- 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:
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 Responses
Hi ,
This is a great article, thanks for sharing about Tableau