• Bernard

Dynamically grouping and ungrouping dimensions in Tableau

What is grouping?

Grouping refers to act of combining related members in a field. For example, when working with data that contains country names, you might want to combine several countries to create a region e.g. combining Kenya, Tanzania, Uganda, Rwanda, Burundi and South Sudan to create ‘East Africa’ region.

Grouping data can also be useful in:

  • Correcting data errors e.g. combining Africa, Afrika, Afric, African, Afrikan into a single data point ‘Africa’

  • Answering what-if type of questions e.g. What would happen if we combine East and West regions?

Useful: Example of dashboard answering what-if type of questions

Ways of grouping data in Tableau

There are several ways you can group related members in Tableau.

Grouping a field in the data pane

Right-click the field you want to group its members, Create >> Group…

Group related members by selecting them, and then click Group.

Rename your group accordingly.

Grouping a field in the view

You can also group members by selecting related members in the view and then clicking on Group icon.

In this example, I would like to combine the highlighted countries to create a region called West.

Creating dynamic groups using calculated field and parameter

Sometimes you might want to present your analysis using either grouped or ungrouped members of a dimension. To do so, you will need to leverage parameter with a calculated field.

In this example, using Superstores dataset, lets create a view that will be grouping product Sub-categories into ‘Technology’, ‘Furniture’ and ‘Office Supplies’ category.

Create parameter – ‘Group & Ungroup’

Create a parameter consisting a list of values as shown below.

Useful: Learn how to create a parameter in Tableau

Create the calculated field below – Dynamic grouping/ungrouping

  • Now drag the calculated field – Dynamic grouping/ungrouping to the rows shelf

  • Drag Sales to the columns

  • Show parameter control

Note by selecting group or ungroup in the parameter control will be grouping and ungrouping product Sub-categories into Technology, Furniture and Office supplies categories.

I hope this article was somewhat helpful to you. To receive more of the Tableau tips and tricks, kindly join our mailing list by subscribing below.

Thank you for reading.