How to create an interactive view that separates 2 dynamic groups

If you collect large sets of data that you want to visualize, you might find that limiting the amount of information displayed to an important subset of records helps you work with and answer questions about the data more effectively. 

Today we will see how to create an interactive view that separates the states in the Superstore data set into two dynamic groups based on sale: 

The top N states by sale

All other states by sale

 The view will include a control that the users can adjust to change the number of states included in the top states group. When they change the number, the view updates accordingly. 

Step 1: Create a parameter

 In Tableau Desktop, we will open a new workbook and connect to the Sample-Superstore data source.

Open a new worksheet. 

 In the Data pane, click the drop-down arrow in the upper right corner and select Create Parameter. 

In the Create Parameter dialog box, do the following: 

                     In the Name text box, type Top States

                     For Data type, select Integer

                    →  For Current value, type 5

This parameter will be used, in combination with the top N set you will create in the next step, to quickly adjust the top N value in the view. 

Step 2: Create the top N states set 

In the Data pane, right-click the State/Province dimension and select Create > Set. 

In the Create Set dialog box that opens, do the following: 

→  In the Name text box, type Top N States by Sales

Click the Top tab

From the field drop-down list (Category), select Sales 

From the aggregation drop-down list, select Sum

Click OK

 Step 3: Set up the view 

From the Data pane, drag Top N States by Sales to the Rows shelf. 

Drag the State/Province dimension to the Rows shelf, positioning it to the right of the set. 

Drag the Sales measure to the Columns shelf. 

On the toolbar, click the Sort Descending button to make sure that the set is working. 

In the Data pane, right-click the Top N States by Sales set, and then click Create Calculated Field. 

In the Calculated Field dialog box that opens, complete the following steps: 

       → In the Name text box, type Subset Labels 

       → In the Formula text box, type the following formula to create dynamic labels for the states in the set: 

IF [Top N States by Sales] 

THEN “Top ” + str([Top N States]) + ” States” 

ELSE “Others” 

END 

       → Click OK 

From the Data pane, drag Subset Labels to the Rows shelf, placing it between the Top N set and the State/Province dimension. 

On the Rows shelf, right-click the IN/OUT(Top N States by Sales) set, and then clear Show Header 

This hides the In/Out labels while retaining the sort order so that your top N subset always appears at the top of the view. 

From the Data pane, drag the Top N States by Sales set to Color on the Marks card. 

Step 4: Combine the Top N set with a dynamic parameter 

In the Data pane, right-click Top N States by Sales, and then select Edit Set. 

In the Edit Set dialog box, do the following: 

     → Select the Top tab. 

     → Click the value drop-down menu and select the Top States parameter. 

     → Click OK.  

This links the Top N States by Sales set to the Top States dynamic parameter, instead of to a static list of 10. 

In the Data pane, under Parameters, right-click the Top States parameter, and select Show Parameter. 

You can control the top N value by using the Top States parameter control that appears in the view. 

Step 5: Group the states not in the Top N in a single value

Create a calculated field and call it Grouped States 

In the Formula text box, type the following formula to create dynamic labels for the customers in the set: 

IF [Top N States by Sales] 

THEN [State/Province] 

ELSE “Others” 

END 

From the Data pane, drag Grouped States directly on top of the State/Province field on the Rows shelf, so that it replaces it. 

 Chart in Tableau Public:

 

Watch the video tutorial here:

About btProvider:

We hold all possible technical and sales certifications for all products:

Tableau Desktop, Tableau Public, Tableau Server, Tableau Prep, and Tableau Data Management.

With Tableau Software – the best data visualization platform – you can always understand your business or your job better. Using Tableau, you will take intelligent and strategic decisions and quickly understand the data flow, numbers and the results it produces. See other #skillpill video tutorials here:

How to display multiple insights on a dashboard in #Tableau

How to create Stacked Bars on Grand Totals in Tableau

How to create a Buffer Zoom in a Tableau Map

Are you interested in learning more about Tableau Software – one of the best analytics tools and implementing the solution in the entire company? 

Contact us!

See how Tableau works, by downloading a free trial here: