# How to track your KPIs using Top N or Bottom N chart in Tableau – Skill Pill Video

Today we all have access to data. Every day, data about our organization provides us with valuable information about our results, market trends or decisions that should be made in our company. KPIs, customer information or their behavior are just some of the information that can be easily found in our data. But in order to build any analysis or visualization, the way we choose to approach data must start from simple, but essential points. In today’s blog post, we will discuss the Top N or Bottom N chart in Tableau, how it is represented and what are the situations in which we use it.

Companies, regardless of their field of activity, have in common a certain principle: to offer and sell high quality products and services to customers and the public interested in them. There are situations in which it is necessary to identify the customers who generated the highest and weakest sales. For this, but also to build customer loyalty programs based on the trust given to our company, we need analyzes that show us the top customers based on sales or other parameters.

#### How to use the Top N or Bottom N chart

Top N or Bottom N chart refers to the first ones and last ones, where N is a value selected by the user that can be static or controlled by a parameter. For example, we can compute the first or last 5 customers depending on the values of their orders. We can also display which were the first and last 10 areas in which our organization operates, depending on the registered profit.

In order to use the Top N or Bottom N chart, it is necessary to know which KPIs we are following. Considering this, we can create Top N or Bottom N of a dimension based on a measure. Using the Top N or Bottom N chart in Tableau gives us more interactivity when we choose to visualize our KPIs. Adding new parameters to the chart, we will have the opportunity to choose in the same visualization the first N or the last N clients depending on the measure or the indicator followed.

Below you will find the steps you need to go through to create a Top N or Bottom N chart and add interactivity to your analysis. In the example below we will display which are the first and last N customers depending on our sales.

#### Step 1: Connect to data

→ In Tableau Desktop, connect to Superstore sample data provided by  Tableau.

#### Step 2: Create the visualization

→ Drag the Sales on Columns and the Customers on Rows.

→ Change the visualization type to Bar Chart.

→ Create a parameter, name it Top N. From the Data Type select Integer and for Current Value type in 5.

→ Create another parameter, name it Top or Bottom. From the Data type select String and from the Allowable Values select List and type in the value asc to pe displayed like Bottom and the value desc to be displayed like Top.

→ Create a calculated field named Rank with the formula:
RANK_UNIQUE(sum([Sales]),[Top or Bottom])

→ Create another calculated field named Filter for Top/Bottom with the formula:
[Rank]<=[Top N]

→ Drag the calculated field Rank on Rows before the field Customers and convert it to Discrete.

→ Drag the calculated field Top/Bottom on the Filters area and select the value to be True.

→ Show the parameters in order to have interactivity.

→ Now you can select if you want to see top or bottom N Customers by Sales.

By Adelina Popescu