top of page

How to Create Interactive "Scroll" Buttons in Tableau

Updated: Oct 19, 2022

Tableau has some incredibly powerful tools for interacting with your data. This 4-part series contains a number of tips and tricks for leveraging those tools to build business dashboards that are more flexible, more engaging, more powerful, and generally, just a lot more fun to use. This is part 3 of the series and covers how to use "Scroll" buttons to limit the results in your view and allowing your users to scroll through "pages" of results. Check out the Resources below for a link to the dashboard referenced in this blog post, and to a short video demonstrating all of the steps in this post.

Resources:

 

Often times we end up with dimensions that need to be visualized in our dashboards, but that have thousands of unique values. Rendering all of these marks in Tableau can have significant impacts on your dashboard's performance. A common practice is to limit the results to the top "N". But what if users need to see the next set of records, or the set after that. In this post we will discuss how to use "Scroll" buttons that allow your users to view one set of records at a time and use buttons to move to the next set.


First, we are going to create two worksheets, one for the left (or decrease) button, and one for the right (or increase) button.

  1. Create a new worksheet named "Range Decrease"

    1. Create a calculated field called 0 with just a 0 in the body of the calculation

    2. Create a calculated field called 1 with just a 1 in the body of the calculation

    3. Drag both the 0 and 1 fields to Detail

    4. Change the mark type to "Shape"

    5. Click on Shape and select the left facing filled arrow ◄

  2. Create a new worksheet named "Range Increase"

    1. Drag both the 0 and 1 fields to Detail

    2. Change the mark type to "Shape"

    3. Click on Shape and select the left facing filled arrow

Next, we want to add these worksheets to our dashboard

  1. Drag a horizontal container on to the dashboard

  2. Drag both worksheets into the container

  3. Hide the titles (right click and select "Hide Titles"

  4. Position the container below the worksheet you want to control and resize it

Now, we want to create a parameter that we can use to set a "range" of records to include in the view

  1. Create a parameter called "Lower Range"

  2. Set the Data Type to Integer

  3. Set the Current Value to 1

Now we are going to create our filter

  1. Go to the sheet that you want to control (In this example it is the "Metric by Manufacturer" worksheet)

  2. Create a calculated field called "Range Filter"

    1. INDEX()>=[Lower Range] and INDEX()<[Lower Range]+10

    2. This will display 10 records at a time. If you want to show more/less records you can adjust the 10 value at the end of the calculation. You can also use a parameter if you want to make the number of records displayed dynamic

  3. Drag the "Range Filter" field to the filter shelf and filter on True

When we click on a button we want it to adjust the Lower Range parameter, which will adjust the "range" of records that are displayed. When we click on the left arrow we want to decrease the range by 10. When we click on the right arrow we want to increase the range by 10. But we also want to make sure that the parameter value doesn't go any lower than 1, or any higher than the number of values we have in our dimension, as no records will be displayed. We essentially want to "turn off" the buttons when they hit their upper or lower limit. We'll start with our left (or decrease) button.

  1. Go to the "Range Decrease" worksheet

  2. Create a calculated field to test if the range is already at its lower limit and call it "Lower Range Limit"

    1. [Lower Range]=1

  3. Drag the "Lower Range Limit" field to color and update the color for the True and False values

  4. Create a calculated field that will be passed to the parameter called "Range - Decrease"

    1. IF [Lower Range Limit] THEN 1 ELSE [Lower Range]-10 END

  5. Drag the "Range - Decrease" field to Detail

Now we'll repeat for the "Range Increase" worksheet but with some modifications to the calculations.

  1. Go to the "Range Increase" worksheet

  2. Create a calculated field to test if the range is already at its upper limit and call it "Upper Range Limit"

    1. [Lower Range]+10>={ FIXED : COUNTD([Manufacturer])}

  3. Drag the "Upper Range Limit" field to color and update the color for the True and False values

  4. Create a calculated field that will be passed to the parameter called "Range - Increase"

    1. IF [Upper Range Limit] THEN [Lower Range] ELSE [Lower Range]+10 END

  5. Drag the "Range - Increase" field to Detail

Next, we want to add a Parameter Action for each of our buttons to pass the Increase/Decrease values to our parameter

  1. Click on Dashboard > Actions

  2. Click "Add Action"

  3. Select "Change Parameter"

  4. Give the parameter a name

  5. Under Source Sheets, select the "Range - Decrease" worksheet

  6. Choose "Select" under the "Run Action On" options

  7. Under "Target Parameter", select the "Lower Range" parameter

  8. Under "Field", select the "Range - Decrease" field

  9. Your final parameter action should look like this

Next you'll want to repeat the steps above for the "Range - Increase" button. Note the differences below

  1. Under Source Sheets, select the "Range - Increase" worksheet

  2. Under "Field", select the "Range - Increase" field

  3. Your final parameter action should look like this

Now when you click on a button you'll see that the range of records adjusts. However, each time you navigate to a new set of records the axis automatically adjusts. We still want to size all of the marks relative to the highest value, as it would be if all of the marks were present in the view. We can't fix the axis because it can change depending on what metric is selected and what filters are applied. Instead we are going to use a reference line to artificially fix the axis based on the highest value.

  1. Go to the "Metric by Manufacturer" worksheet

  2. Create a calculated field called "Range Ref Line"

    1. WINDOW_MAX([Metric Calc])

  3. Drag the "Range Ref Line" field to Detail

  4. Add a reference line

    1. In the left window, click on Analytics

    2. Click on Reference Line and drag it to "Table"

    3. Next to Value, select "Range Ref Line" and set aggregation to Minimum

    4. Set Label to "None"

    5. Set Tooltip to "None"

    6. Set all Formatting to "None

    7. Your Reference Line options should look like this

Now as you scroll through the records, the axis remains fixed. However, you may notice that you need to click on a button multiple times to complete the scroll action. Once a mark is selected by clicking on it, you need to click again to deselect it, and then again to drive another action. We can prevent this by using the Filter Action method we had outlined in Part 2 of this series. Use the process outlined in that post to add a Filter Action to both the "Range Decrease" and "Range Increase" worksheets. For convenience, here is a quick review of that process

  1. Click on Dashboard > Actions

  2. Click "Add Action"

  3. Select "Filter

  4. Give the Action a name

  5. Under Source Sheets select the "Range Decrease" worksheet

  6. Under Target Sheets click on the drop-down and select the "Range Decrease" worksheet (do not select it from the default display list)

  7. Choose "Select" under the "Run Action On" options

  8. Under "Clearing Selection Will" select "Show All Values"

  9. Under "Target Filters" choose "Selected Fields"

  10. Click the "Add Filter" button

  11. Under the "Source" Field choose 0

  12. Under the "Target" Field choose 1

  13. Click OK

  14. Repeat this process for the "Range Increase" worksheet

That is it for today. Keep an eye on our blog for Part 4 of the series which will cover how to add an instruction "overlay". If you have any questions or comments on these tips, please let us know at info@cleartelligence.com.

bottom of page