This is part 2 of a 2-part series. For part 1, click here.
In Part 1, we learnt how to create Sets and use the Sets view to change members in the Set. In this tutorial, let us learn how to get Top/Bottom members in a Set and how to make this value dynamic. Just as the previous post, use this dataset to follow along. This data is about the spending patterns of customers, the categories and items they spend on and some details about transactions.
Use Case
Suppose you want to know which your Top (or Bottom) categories by Unit Price are, but you would rather have the user determine the number of Top or Bottom categories they want to view, you can use Sets with a Parameter function to achieve this. Let us see how:
Right-click on Category in the Data Pane, select Create, and select Set.

A new window will appear. In the Name field, give it a name. You can call it whatever you like. I have called it Top N Set. Then click on the Top tab.

For the By Field option, click on the dropdown and select Create a New Parameter.

A new window will pop up. Define the new parameter in this window. I have called it Top N and retained the rest of the predefined values that Tableau has generated. Click Ok and then Click Ok for the Set window as well.

First, visualise the parameter. For this, right click on the newly created Top N parameter and select Show Parameter.

Then drag the newly created Top N Set on rows, followed by Category. Drag Price per Unit on Columns. Sort by ascending order and switch the view from standard to Entire View. Then drag the Top N set on the colour marks card. The user can change the number of Top categories using the Top N parameter at the right hand corner to dynamically change the view.


