Grouping our data

Being able to group our data into higher categories is a very useful feature. The data that we connect to may not always have all the fields that are required for our analysis. There are times when we would have to go beyond what is available in the data and create some new fields either by doing some calculations or by using some default features. Imagine having data where we have state names, city names, and so on; but the region field has not been captured in the data. Now, there are going to be instances where we would need to do a region-level analysis. For example, we have state-wise sales but want to see how the sales are at a regional level. This information however, is not present in the data.

It's a good thing we have the Grouping feature in Tableau. We can create a group on the state names and club the relevant states into regions. Let us see how to create and use Groups in the following recipe.

Getting ready

We will continue working in our existing workbook and for the purpose of this recipe, we will use the State field from the Orders data of Sample - Superstore.xlsx data to create groups called Sales Territories for our business managers to look into. Let's see what steps are to be taken to create a Group.

How to do it…

  1. Create a new sheet by pressing Ctrl + M and rename it Groups.
  2. In the Dimensions pane, let us double-click on the State field and then get Sales from the Measures pane and drop it into the Size shelf. This will create a geographic map as shown in the following image:
    How to do it…
  3. Next we will right-click on the State field in the Dimensions pane and select the Create | Group… option. Refer to the following image:
    How to do it…
  4. Once we do that, we will get the following view:
    How to do it…
  5. Let us give a name to this Group. Let us call it Sales Territories by typing the name in the Field Name input box at the top.
  6. We will notice the Find >> button at the bottom-right corner. We can expand this section to see what further options are available for us to use. Refer to the following image:
    How to do it…
  7. Once we get the necessary type-in box, we will keep all the dropdown selections as they are and just type the word New in the type in box and make sure that we keep the bottom dropdown selection as Contains and then click on the Find All button. Please note that the type-in box is not case sensitive.
  8. Once we do that, Tableau will give us a selection of all the members that contain the word New in it. We will then click on the Group button. Refer to the following image:
    How to do it…
  9. We will now get a Group called New Hampshire, New Jersey, New Mexico and one more. Let us rename it Territory 1 by right-clicking on the new group or by clicking on the Rename button which is right next to the Group button. Once we do that, we will see a paperclip symbol:
    How to do it…
  10. Now, New Hampshire, New Jersey, and New York are all on the East side of the US map. However, New Mexico belongs to the West side of the US map. We need to remove it from our newly created group called Territory 1: right-click on New Mexico and choose the Remove option. Refer to the following image:
    How to do it…
  11. Further, let us add a few more states, such as Connecticut, Delaware, District of Columbia, Florida, Georgia, Maine, Maryland, Massachusetts, North Carolina, Pennsylvania, Rhode Island, South Carolina, Vermont, and Virginia to this Territory 1 group by right-clicking on each one of the states in the preceding dialog box and selecting the option of Add to…. Refer to the following image:
    How to do it…
  12. Let us add all those states to our group called Territory 1. Once we do that, we'll also create another group called Territory 2 on states such as Idaho, Montana, Oregon, Washington and Wyoming. Similarly, we will create another group called Territory 3 on states such as Arizona, California, Colorado, Nevada, New Mexico and Utah. This will give us three groups. To group the remaining states together, click on the checkbox which says Include 'Other'. Refer to the following image:
    How to do it…
  13. Once we do that, we get a group called Other. We will click on that group name and select the Rename option to call it Territory 4. Let us click on the OK button once we are done.
  14. We will then see a new Dimension called Sales Territories in the Dimensions pane. Refer to the following image:
    How to do it…
  15. As a final step, let us drag and drop the Sales Territories field in the Color shelf. Refer to the following image:
    How to do it…

How it works…

This Group that we just created is now part of the Dimensions pane and is available for us to use across the entire workbook.

Another way of creating quick Groups is to select multiple marks in an already created view and selecting the Paper clip icon from the tooltip. Refer to the following image:

How it works…

Tip

Please note that we create Groups on data members within a field. That means multiple members of a field can be grouped together. However, multiple fields can't be grouped together.

The above-mentioned functionality of selecting multiple mark types on the view can further be extended to create what we call Custom Territories in Tableau. We've already seen a way of creating Custom Territories in the previous chapter. In this chapter, we'll now look at how to use Groups to create Custom Territories. In order to do so, we first create a filled map at state level and then visually group the States as shown in the following image:

How it works…

This action will result in creating an on-the-fly group called State (group) in the Dimensions pane. This new group will further be automatically placed into the Color shelf and our view will update as follows:

How it works…

If we remove the State field from the Detail shelf, our view will update to give us a filled map at a State (group) level. Refer to the following image:

How it works…

This functionality is referred to as the Custom Territories. Further, the color legend can be updated to read as Zone 1 and Zone 2 by right-clicking on the text and selecting the Edit alias… option. Refer to the following image:

How it works…
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.82.4