top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

Grouping in Tableau

Grouping can be used as simple data preparation. For example, you might need to group values due to incorrect spellings or you may need to group people into teams.

Groups are a manual process because they are based on data that's already in your data source.

Let's see how to manually group data to compare it to a newly created product group:

  1. Right-click Product Name, then choose Create --> Group.

2. This allows you to create groups and select values to include in the group. Rename the group by editing the Field Name at the top to "Z Products Group". 3. Select the items from the list that you would like to group; then click Group. To multiselect, press Shift as you select the first and last item.


4. While still highlighted, type in the box to rename the group to Z Products. You can repeat this as many times as needed.

5. To group all the other ungrouped products in to a group called "Other", check the "Include 'Other' " checkbox. This would allow you to compare the created groups against all the other products in group.

6. Once you have added all your groups, click OK.

7. Find the group in the Data pane and double-click it.

8. Drag Sales onto Columns

As you can see in the above picture, grouping is very effective in comparing a certain set of data against other data groups and visualize the comparison as needed.

There are three methods for grouping data:

  • Visual Grouping

  • Discrete Grouping

  • Conditional Grouping

Visual Grouping

In visual grouping, we use a chart to create a group using highlighted dimensions. Let's see how to create a visual grouping.

  1. Create a horizontal bar chart with Product Name and Sum of Sales, sorted descending.

  2. On the bars, click and lasso the marks to highlight the top 10.


3. Hover over a highlighted bar and select the paper clip icon. This creates a new group as a field in the Data pane, with the selected product names and adds it to the Color on the Marks card.



Visual Grouping is useful for seeing where marks are displayed within the view as Tableau automatically adds the group onto the Color property of the Marks Card.


Discrete Grouping

Discrete grouping can be used to group similar products using their names instead of their sales position.

  1. Create a horizontal bar chart with Product Name and Sales(Sum).

  2. Hover over the start of the bar until you get a horizontal arrow. Drag right until you see the full product name for the product of your choosing.


3. Press Ctrl, select all the products of the chosen name. Click the paper clip icon to group.

Tableau groups the products into one bar and does not add the group to color.

This type of grouping is good for spelling mistakes or to combine dimensional fields. The grouping has added an "&" into the name of the product.

Let's change the group name and remove the "&":

Right-click the dimension and select Edit Alias. This allows you to change the name of the subgroup.

The grouped field will now look like this:

Finally, Right-click and re-name the "Product Name(group) 1" field in the Data pane.

Once you have the new group of products, if you do not want to use the old Product Name field going forward, you have to replace the references. To do so:

1. Right-click Product Name and select Replace References.

2. Find the field you want to replace it with, then click OK.

Product Name field has now been replaced with Discrete Product Name in the Data pane.


Finally, let's hide the original Product Name field to avoid confusions. To do so:

Right-click the "Product Name" field and select Hide. The field will now be hidden from the Data pane.

To get back any hidden fields, click the drop-down next to the search box within the Data pane and select show hidden fields.

This will now show the hidden fields as light gray in the Data pane. To unhide a field, right-click and select Unhide.

Conditional Grouping

Conditional grouping is grouping of data based on a certain condition. Let's consider grouping three groups based on whether the profit of a sub-category is greater than or equal to $20K, greater than or equal to 0, or below 0. To achieve this grouping, a conditional IF statement would be needed.

  1. Create a horizontal bar chart using Sub-category and Profit (sum) and sort by descending.

If Sum([Profit])>=20000
    THEN 'High'
ELSEIF Sum([Profit])>=0
    THEN 'Low-Middle'
ELSE 'No Profit'
END

Click OK.

2. Drag the Conditional Profit Grouping calculation to Color on Marks card.

The sub-categories in the bar chart would now be split into the respective conditional categories based on the IF statement.

Conditional grouping is good when you have constant targets. You can create as many or as few conditional groups as you like.












38 views0 comments

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page