# How to Integrate Pagination in Tableau: Part 1

You can build all the beautiful charts in the world but sometimes itâ€™s something as simple as a table thatâ€™s going to fit the clientâ€™s needs. However, if youâ€™re dealing with a lot of data, this can be overwhelming with what feels like endless scrolling. Thatâ€™s where pagination comes in. There are a lot of ways to do this. In fact,Â hereâ€™s a method by Luke StankeÂ also on our blog. But I wanted to show you how I do it and some of the things I consider when setting it up.

Hereâ€™s our pagination recipe:

• 1 ParameterÂ
• 4 Sheets
• 5 CalculationsÂ
• 2 Parameter Actions

## Create an Integer Parameter

The first sheet will just be the table that you would like to apply this to. For this example, Iâ€™ll be using Superstore data and looking at sales by customer. Next, create an integer parameter allowing for all values (itâ€™ll be referred to as â€˜Page Numberâ€™ in this blog). This is what weâ€™ll use to change the page number the user is on.

## Make First Calculation to Filter the Table

Now weâ€™re going to make our first calc. This will be used to filter the table we previously created to a specific number of values corresponding with the page weâ€™re on. Here youâ€™ll have to decide how many rows to display on each page. Iâ€™m going to use 20. If you would like to keep this flexible and let the user choose, you can add a second parameter here to allow them to change the number of rows per page.

```				```
INDEX() <= [Page Number] * 20

AND

INDEX() > [Page Number] * 20 - 20
```
```

Explanation: The index will return the row number. We only want to display 20 rows per page. This calc looks at the page number and multiplies it by 20 to find the row number of what would be the last row on the page. Subtracting 20 from that value gives us the row number for the first row on the page. This calc returns whatâ€™s in between.Â

Place the calc you just created on the filter shelf of your table and set it to true with the table calc going down the table.Â

Letâ€™s also create a calc to tell us how many pages there are in total. This will be helpful in several places.Â

```				```
CEILING(COUNTD([Customer Name])/20)

```
```

Explanation: The distinct count of customers tells us how many rows there are in the table in total. Weâ€™re dividing that by 20 (the number of rows per page) to see how many pages there are for the data. Weâ€™re taking the ceiling of that to account for the fact that there will likely be a total number of rows thatâ€™s not cleanly divisible. The ceiling is like round if round always went up. For example, if there were 39.45 pages, youâ€™d actually have 40 pages.Â

## Navigating Between the Sheets

Next, weâ€™ll need to create a way to navigate between the sheets. We will do this with two more calcs, two more sheets, and two-parameter actions with one of each being used to go forward and the other backward. Letâ€™s start with forward.Â

```				```
IF [Page Number] < [Total Page Numbers] THEN [Page Number] + 1 ELSE 1 END
```
```

Explanation: If we arenâ€™t at the last page, we want to add one to the page parameter to take us to the next page. If we are at the last page, we want to go back to the first page.Â

On a new sheet, youâ€™ll take this value and put it on rows as a discrete measure. Choose your desired mark type. I usually use an arrow thatâ€™s pointing to the right but a â€˜+â€™ sign or the words â€˜next pageâ€™ will work as well. Make some slight formatting adjustments by unshowing the header and removing borders. Add this to your dashboard with your table. Go to Dashboard > Actions and create a new parameter action. Select the sheet you just created, choose select in the â€˜Run action onâ€™ section, put your â€˜Page Numberâ€™ parameter as the parameter, the calc from that sheet as the field, the aggregation as â€˜Noneâ€™, and keep the current value when clearing the selection. Youâ€™ll now find that pressing the mark on this sheet moves the pages forward.

Now to go the other way. Itâ€™s very similar.Â

```				```
IF [Page Number] > 1 THEN  [Page Number] - 1 ELSE [Total Page Numbers] END
```
```

Explanation: If weâ€™re not on the first page then subtract 1 from the page number parameter, otherwise, go to the last page.Â

Setting up this sheet is the same as the previous method. Though for the mark type I normally use an arrow pointing to the left (â€˜-â€™ sign or â€˜last pageâ€™ will work). Add this sheet to your dashboard and add another dashboard action with the same settings we used before.Â

Technically we can stop here! You have successfully constricted the number of rows in your table and allowed the user to move forwards and backward through the pages. But thereâ€™s a couple of things I like to add.

## Adding Total Number of Pages

Your user might not be familiar with the data and therefore might not know just how much of it there is. Letâ€™s tell them. Something I like to add with this method of pagination is another sheet with the total page numbers and the page that theyâ€™re on. And this is really simple because it uses things youâ€™ve already seen.Â

On a new sheet, add the â€˜Total Page Numbersâ€™ calc to text along with a calc containing just the â€˜Page Numberâ€™ parameter (I usually just do an ad hoc calc for this). Edit the text to the following.

```				```
Page <Parameters.Page Number> of <AGG(Total Page Numbers)>
```
```

Add this sheet to your dashboard between the buttons you created to toggle forward and backward through the table.

## Restricting the Buttons

One final touch I usually add is to restrict the buttons and page number to only be visible if thereâ€™s more than one page. This step will be dependent on your data and the filters available on the dashboard, but in the scenario that there is only one page, the user wouldnâ€™t need pagination. Use the following calc [set to True] as a filter across the page number and button sheets.Â

```				```
[Total Page Numbers] > 1
```
```

## In Conclusion

And there you go, this is how I accomplish pagination. But there are many ways to do it and many considerations to make. Be on the lookout for future blogs on extra things you can add to amp up this method even more.

Need more help making your Tableau dashboards a work of art? Our knowledgeable team of Tableau experts is here to help!

## Other Technology Partners

Introducing
Data Coach is our premium analytics training program with one-on-one coaching from renowned experts.