Author: Srutimala Deka
Brief Introduction to Tableau
Tableau is a visualization tool for analytics purposes. It is one of the leading analytics and visualization tools owing to its simplicity of use. The tool utilizes a drag and drop method, which takes little to no effort to pick up. This saves on a lot of training hours.
What is pagination?
Pagination is nothing but the sequence of numbers used to signify pages in the view. Usually, Tableau will accommodate a tabular sheet as far as the height of its container will allow. Beyond that, a scroll bar is introduced.
Now, there can be situations where the scroll bar may not be the most helpful addition. One example is shown below.
In the dashboard, we are displaying customers (from the sample superstore data) and the sales and profit they generate in two bar charts. There are two sheets made to behave as a single sheet in the dashboard.
The problems faced in this view are:
a) Each sheet needs to be scrolled individually. But the sheets are not independently interpretable; hence it doesn’t make sense to scroll them separately.
b) It reduces the overall quality of the dashboard.
a) Synchronized scrolling using a tableau work-around using index and parameter is one solution. It works beautifully until we reach the end of the scroll bar, and we end up with blank pages. Even worse, when we underestimate the data points to show. In that case, we risk leaving out data from the view completely.
For a huge database, this method would also be slow.
b) The second option is to divide the data into different pages based on a common field in each view.
This is what pagination will do.
How to achieve pagination in Tableau?
There are six calculations to trick Tableau for this solution. But first, we must create two parameters listed below:
Parameter 1) Rows per page
This parameter determines how many rows to display for each page number.
Parameter 2) Page number
This parameter is used to control the current page number on display.
Next, the calculations are created as given step by step below-
Calculation 1) Pagination Index
This will give us a sequence of numbers and become the page numbers that the user can click to navigate.
Calculation 2) Pagination Object Index
This calculation will place our common field (in our case, Customer Name) on the appropriate page. This is achieved by assigning a pseudo index value to the rows. No matter the value of ‘pagination index,’ this calculation will always amount to the value 1.
Calculation 3) Pagination page t | f
This will be set to True for each sheet in our dashboard so that our individual sheets adhere to the same page number with the same Customer Names.
Calculation 4) Pagination page n | 0
This calculation will trick Tableau to display the right number of rows derived from the index.
So that the final index looks like this (highlighted in lime green):
We will hide this field from the view later.
Calculation 5) Select page number
Finally, we will distinguish between selected and not selected page numbers using calculation five above and calculation six below.
Calculation 6) Not select page number
Putting it all together
Let’s create the sequence of page numbers by dragging the following fields as shown below:
a) Compute all table calculations with respect to Customer Name, the common field between all our sheets.
b) Hide header for the field in Columns mark.
c) Set ‘Pagination page n | 0’ to 0 in the filters.
Lastly, in each sheet, filter for the field ‘Pagination page t | f’ to True and compute using Customer Name.
The final touch is to add parameter action on the dashboard:
Source field is not a page number. This will modify the target parameter to set the page number to the new selected page number.
When done, our Dashboard looks like this -
Eliminating the scroll bars thus makes it possible to show multiple charts in a tabular format without compromising on user experience.
Reference: This blog wouldn’t be possible without this article which inspired me to do unconventional tasks in Tableau and to think outside the box.